I''m switching over to RESTful routing and was looking forward to using the nested routing to make things a lot more convenient. However I''ve found that I don''t seem to be able to use both nested routes AND "direct" RESTful routes on the same controller. For example, I would like to have both of these URLs: /invoice/1 /user/5/invoice/1 Actually, the above seems to work from a routing standpoint. Using *_path to construct my links does not seem to work. If I have: map.resources :invoice map.resources :user do |user| user.resources invoice end ...then this will not work: invoice_path(invoice) It constructs a path like "/user/1/invoice". If I change the order in routes.rb and do the nested route first, the direct URL is correct but I can''t specify a parent any longer in *_path. Any ideas? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sorry for the reply to myself, but I found a solution: http://dev.rubyonrails.org/ticket/5761 Basically, :name_prefix in the nested route definition allows me to differentiate between direct & nested in *_path. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Carl Johnson wrote:> Sorry for the reply to myself, but I found a solution: > > http://dev.rubyonrails.org/ticket/5761 > > Basically, :name_prefix in the nested route definition allows me to > differentiate between direct & nested in *_path.Yes, this solves your question, but how can you manage to have only one controller using correctly the named routes in the views. Two sets of named routes and only one set of views, if you want stay DRY. This is the problem I am questioning in a similar thread (Single Table Inheritance and RESTful routes), If you find a solution, please, I will thank you if you let me know. Juan M. Cervera -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---