routes

ASP.Net MVC support for Nested Resources?

狂风中的少年 提交于 2019-11-30 08:46:44
I'm looking for a routing option similar to the nested RESTFul routes functionality available through Rails. The SimplyRestful project on MvcContrib doesn't appear to be active any longer nor does it appear to be current with the 1.0 MVC release. This is the uri scheme I'm looking for, /Activity/10/Task/1/Edit or /Activity/10/Task/Edit/1 I simply haven't been able to get it to work and all the documentation I've run across describes the non-nested scenario. It doesn't seem like it'd be that difficult.... This is what I've been working with... routes.MapRoute(null, "Activity/{activityId}/Task/

What does (.:format) mean in rake routes' output?

和自甴很熟 提交于 2019-11-30 08:34:57
What does (.:format) mean in rake routes ' output? users GET /users(.:format) users#index If you check the index action of your Users Controller then you will see something like this def index @users = User.all respond_to do |format| format.html # index.html.erb format.json { render json: @users } end end So, this format is the type of response which will be generated. In routes, a placeholder for the type of response is created irrespective of whatever format has been defined in the action of the controller. So, if your URL is something like :- users GET /users --> users/index.html.erb will

Laravel form html with PUT method for PUT routes

允我心安 提交于 2019-11-30 08:00:55
I Have this in my routes : +--------+---------------------------+--------------+--------------------------- ---------+----------------+---------------+ | Domain | URI | Name | Action | Before Filters | After Filters | +--------+---------------------------+--------------+--------------------------- ---------+----------------+---------------+ | | GET|HEAD / | | postcontroller | auth | | | | GET|HEAD login | | homecontroller@dologin | | | | | POST login | | homecontroller@dologin | | | | | GET|HEAD logout | | homecontroller@dologout | | | | | GET|HEAD post | post.index | postcontroller@index | |

Rails 3 Custom Route that takes multiple ids as a parameter

旧巷老猫 提交于 2019-11-30 07:02:46
问题 How do I add a route to my Rails 3 app which allows me to have a URL that maps to an action in a RESTful resource that accepts multiple parameters: /modelname/compare/1234,2938,40395 And then in my controller, I want to access these ids: @modelname = Modelname.find(params[:modelname_ids]) So far, I have been trying match '/modelname/compare/:modelname_ids', :to => 'modelname#compare' , but I keep getting No route matches "/modelname/compare/4df632fd35be357701000005,4df632fd35be357701000005" .

Laravel passing data using ajax to controller

痞子三分冷 提交于 2019-11-30 06:47:19
问题 How do I pass the id from this ajax call to the TestController getAjax() function? When I do the call the url is testUrl?id=1 Route::get('testUrl', 'TestController@getAjax'); <script> $(function(){ $('#button').click(function() { $.ajax({ url: 'testUrl', type: 'GET', data: { id: 1 }, success: function(response) { $('#something').html(response); } }); }); }); </script> TestController.php public function getAjax() { $id = $_POST['id']; $test = new TestModel(); $result = $test->getData($id);

Trigger same location route

喜你入骨 提交于 2019-11-30 06:40:27
Is there a way to trigger same location route in backbone.js, for example when location is /My/App/#/About and user clicks again on anchor with the same route in order to refresh the page content. Router.navigate('about', true); That way you can trigger a route manually. Backbone.history.loadUrl(Backbone.history.fragment); The solution for your specific problem isn't really documented and it seems the suggested best practice is to just call the function that is declared in the route you want to fire :/ Ref: https://github.com/documentcloud/backbone/issues/1214 So far the other answers are

play framework2: remove trailing slash from urls

橙三吉。 提交于 2019-11-30 06:25:11
问题 In play framework 1, you could use in the routes file something like this (check documentation at http://www.playframework.org/documentation/1.2.5/routes#syntax) GET /clients/? Clients.index so that the route will match /api/clients and also /api/clients/ How can I achieve the same in play framework 2? 回答1: From SEO point of view the same link with trailing slash is other one than link without it. It is highly recommended to always use one schema (trailed or un-trailed links). Although there

Flutter Redirect to a page on initState

与世无争的帅哥 提交于 2019-11-30 04:49:31
I have an application where you need to log in to continue (for example with Google). I would like to redirect the user when the authentification is needed. However when I run a Navigator.of(context).pushNamed("myroute") . I got the following error: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ I/flutter ( 5624): The following assertion was thrown building _ModalScopeStatus(active): I/flutter ( 5624): setState() or markNeedsBuild() called during build. I/flutter ( 5624): This Overlay widget cannot be marked as needing to build because the

Rails routing - custom routes for Resources

陌路散爱 提交于 2019-11-30 04:45:11
问题 I'm building currently one Rails app and I'd like to stick to all those fancy things like REST and Resources, but I'd like to customise my routes a little. I want my GET route to be little more verbose - the app I'm creating is a simple blog, so instead of GET /posts/1 I'd prefer something like GET /posts/1-my-first-post . Any ideas how to do this? Didn't find anything on the web. 回答1: Routes: map.resources :posts Model: class Post < ActiveRecord::Base def to_param "#{id.to_s}-#{slug}" end

OmniAuth doesn't work with Route Globbing in Rails3

蓝咒 提交于 2019-11-30 04:03:50
I am trying to follow the Railscast 241 Simple OmniAuth and it works fine unless I have Route Globbing at the end of /config/routes.rb : match '*uri' => "posts#index" If I request /auth/twitter with the globbing then OmniAuth does nothing: Started GET "/auth/twitter" for 127.0.0.1 at 2011-04-03 19:17:44 +0200 Processing by PostsController#index as HTML Parameters: {"uri"=>"auth/twitter"} Rendered posts/index.html.haml within layouts/application (9.0ms) Completed 200 OK in 103ms (Views: 14.6ms | ActiveRecord: 0.7ms) Without the globbing route it authenticates correctly. Is there a way to have