Steve Wilhelm
2010-Mar-06 22:26 UTC
How to configure nested routers to omit controller from URL?
I have the following nested route in my routes.rb map.resources :users do |user| user.resources :pie_charts end and the ''rake routes'' command shows the following routes: user_pie_charts GET /users/:user_id/pie_charts(.:format) {:controller=>"pie_charts", :action=>"index"} user_pie_chart GET /users/:user_id/pie_charts/:id(.:format) {:controller=>"pie_charts", :action=>"show"} This all works, but I want the URLs to omit "/users," that is: user_pie_charts GET /:user_id/pie_charts(.:format) user_pie_chart GET /:user_id/pie_charts/:id(.:format) Is this possible, and if so how would one go about configuring it? - Steve W. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
petr.blaho
2010-Mar-16 11:30 UTC
Re: How to configure nested routers to omit controller from URL?
Hi, I have the same problem but I need to omit both users and pie_charts from url... and my pie_charts has many others nested resources. If someone know how to do it, please, tell us. With regards Petr Blaho On 6 bře, 23:26, Steve Wilhelm <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have the following nested route in myroutes.rb > > map.resources :users do |user| > user.resources :pie_charts > end > > and the ''rakeroutes'' command shows the followingroutes: > > user_pie_charts GET /users/:user_id/pie_charts(.:format) > {:controller=>"pie_charts", :action=>"index"} > user_pie_chart GET /users/:user_id/pie_charts/:id(.:format) > {:controller=>"pie_charts", :action=>"show"} > > This all works, but I want the URLs to omit "/users," that is: > > user_pie_charts GET /:user_id/pie_charts(.:format) > user_pie_chart GET /:user_id/pie_charts/:id(.:format) > > Is this possible, and if so how would one go about configuring it? > > - Steve W. > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.