I am trying to write a nested route ''new style'' map.resources :franchises, :has_many => :documents in place of the : map.resources :franchises do |franchises| franchises.resources :documents, :name_prefix => "franchise_" end but get an error : no route found to match "/franchises/1/documents" with {:method=>:get} running rake routes, cannot see it... what could be the problem with my Rail install ? thanks -- 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 -~----------~----~----~----~------~----~------~--~---
Kad Kerforn wrote:> but get an error : > no route found to match "/franchises/1/documents" with {:method=>:get}Shouldn''t ''franchise'' be singular when used with an id? -- 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 -~----------~----~----~----~------~----~------~--~---
John Miller wrote:> Kad Kerforn wrote: > >> but get an error : >> no route found to match "/franchises/1/documents" with {:method=>:get} > > Shouldn''t ''franchise'' be singular when used with an id?I tried it too... no route found to match "/franchise/1/documents" with {:method=>:get} a rake routes doesn''t show up any nested route for documents, it seems the :has_many is not seen at all -- 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 -~----------~----~----~----~------~----~------~--~---
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2007-Aug-25 22:19 UTC
Re: REST routes :has_many , new style
Hi -- On Sat, 25 Aug 2007, Kad Kerforn wrote:> > I am trying to write a nested route ''new style'' > > map.resources :franchises, :has_many => :documents > > in place of the : > > map.resources :franchises do |franchises| > franchises.resources :documents, :name_prefix => "franchise_" > end > > but get an error : > no route found to match "/franchises/1/documents" with {:method=>:get} > > running rake routes, cannot see it... > what could be the problem with my Rail install ?Are you running edge Rails? If not, :has_many won''t work. I''ve put your map.resources line in my routes.rb, and I get this in the console:>> r = ActionController::Routing::Routes=> # lots of output...>> r.recognize_path("/franchises/1/documents", :method => :get)=> {:controller=>"documents", :action=>"index", :franchise_id=>"1"} This is on revision 7340 (a fairly recent edge Rails). David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.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 -~----------~----~----~----~------~----~------~--~---
David, I am trying to figure out if this is the intended behaviour map.resources :users, :has_many => [:groups] map.resources :groups, :collection => {:joined => :get, :created => :get} in console I type>> r = ActionController::Routing::Routes >> r.recognize_path("/groups/created", :method => :get)=> {:controller=>"groups", :action=>"created"}>> r.recognize_path("/users/diego/groups/created", :method => :get)=> {:controller=>"groups", :user_id=>"diego", :action=>"show", :id=>"created"} the collections routes for groups are not carried over into the nested version inside of user. Furthermore there is no syntax like has_many => [:posts => {:collections => {:joined => :get} } ] in place. I am guessing that my only options is to repeat any :new, :member or :collections specific routes. Am I guessing right? Diego --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---