routes

nested form_for singular resource

浪尽此生 提交于 2019-11-30 23:49:01
I have a singular nested resource like so: map.resources :bookings, :member => { :rate => :post } do |booking| booking.resource :review end Giving me these routes: new_booking_review GET /bookings/:booking_id/review/new(.:format) {:controller=>"reviews", :action=>"new"} edit_booking_review GET /bookings/:booking_id/review/edit(.:format) {:controller=>"reviews", :action=>"edit"} booking_review GET /bookings/:booking_id/review(.:format) {:controller=>"reviews", :action=>"show"} PUT /bookings/:booking_id/review(.:format) {:controller=>"reviews", :action=>"update"} DELETE /bookings/:booking_id

How to declare a rails resource with a parameter for new action?

时光毁灭记忆、已成空白 提交于 2019-11-30 23:13:23
问题 I have a model named Entree for which the new action needs a parameter, the id of another model named Cave . I don't want to nest Entree in Cave since Cave is already nested. What I did was declaring the resource Entree as follow in routes.rb : resources :entrees, :except => [:new] match "/entrees/new/:id", :to => "Entrees#new", :as => 'new_entree' That works, but the problem is when there's an error in the create action, I want to display the page again with the invalid input. But since

Using form_for tag with get method

大城市里の小女人 提交于 2019-11-30 22:52:24
问题 I am trying to Submit a form using get method. Earlier I was trying a similar thing with form_tag and it was working but now when I changed to a form_for tag, this doesn't seem to work. <%- filter_path = params[:action] == "index" ? posts_path : sneak_peek_posts_path %> <%= form_for(@post_filter, :url=> filter_path, :method => :get) do |f| %> I get a no routes error. 回答1: You can pass the raw HTML attributes using :html if you need to. For Rails 3: <%= form_for(@post_filter, :url=> filter

ASP.NET MVC: Route to URL

天涯浪子 提交于 2019-11-30 22:40:53
What's the easiest way to get the URL (relative or absolute) to a Route in MVC? I saw this code here on SO but it seems a little verbose and doesn't enumerate the RouteTable. Example: List<string> urlList = new List<string>(); urlList.Add(GetUrl(new { controller = "Help", action = "Edit" })); urlList.Add(GetUrl(new { controller = "Help", action = "Create" })); urlList.Add(GetUrl(new { controller = "About", action = "Company" })); urlList.Add(GetUrl(new { controller = "About", action = "Management" })); With: protected string GetUrl(object routeValues) { RouteValueDictionary values = new

link_to update (without form)

独自空忆成欢 提交于 2019-11-30 21:42:37
问题 I want a link to update a resource, without using an HTML form. Routes : resources :users do resource :profile, :controller=>"profiles" resources :friends end Rake routes: user_friend GET /users/:user_id/friends/:id(.:format){:action=>"show", :controller=>"friends"} PUT /users/:user_id/friends/:id(.:format){:action=>"update", :controller=>"friends"} I want to use the put to update a friend by a simple link, something like this: <%=link_to "Add as friend", user_friend_path(current_user,

Set default action (instead of index) for controller in ASP.NET MVC 3

天大地大妈咪最大 提交于 2019-11-30 21:37:53
问题 I have a controller called Dashboard with 3 actions: Summary , Details , and Status , none of which take an ID or any other parameters. I want the URL /Dashboard to route to the Summary action of the Dashboard controller, as /Dashboard/Summary does, but I can't figure out the correct way to add the route. In Global.asax.cs , I have the following: routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new {controller = "Home", action = "Index", id =

Is there a C/C++ API to the route information on Windows?

夙愿已清 提交于 2019-11-30 21:10:56
Is there a windows or cygwin C/C++ API to collect information provided by the route command on Windows? I'm specifically interested in the route metrics. Here's an example of what route outputs, the IPs have been changed to protect the innocent. $ route PRINT -4 =========================================================================== Interface List 11...64 31 50 3b ba 96 ......Broadcom NetXtreme Gigabit Ethernet 17...00 50 56 c0 00 01 ......VMware Virtual Ethernet Adapter for VMnet1 18...00 50 56 c0 00 08 ......VMware Virtual Ethernet Adapter for VMnet8 1...........................Software

mvc route actionlink url use name instead of id

馋奶兔 提交于 2019-11-30 21:10:21
I think I already asked this but the solution didn't really made sense. Anyway, I have ActionLinks on my views like this: foreach( var item in Model){ <%: Html.ActionLink(item.Name, "Details", new {id = item.Id}) %> } now, when it goes to my Action Details obviously this will be the url /MyThings/Details/{id} I was wondering if it's possible to show the name of that item instead of the id Using a slug? or modifying the global asax like so: /MyThings/Details/CarKeys The thing is the names need to be unique, is there a way I can modify the global asax to show the name instead of the id? Any

How to remove “public” from url using routeing in zend framework

北慕城南 提交于 2019-11-30 20:47:04
问题 An one issue in my zend, i write rule in .htaccess to remove "public" from url as following, ------------------------------------------------------------------------ RewriteEngine On RewriteCond %{HTTP_HOST} ^domain-name.com/$ [OR]<br/> ReWriteCond %{REQUEST_URI} !public/<br/> ReWriteRule ^(.*)$ public/$1 [L]<br/> ------------------------------------------------------------------------ but there is ROUTE method in zend, i have use it for multiple language to set language code in url LIKE www

Camel Exception handling doesnt work if exception clause is defined in a separate class

大憨熊 提交于 2019-11-30 20:12:27
I am trying to build a application with several camel routes which re use many common routes internally. Hence, I am trying to segregate the routes in several different Route Builder classes and then connecting the routes where needed. For eg, all routes pertaining to sending emails go into a EmailRouteBuilder class and all routes dealing with a particular JMS Queue go into MyQueueRouteBuilder class. I suppose this should be alright since Camel doesnt not distinguish between classes and only looks for routes defininition. In addition, I am also grouping several exception handling routes into a