Hi --
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
Diego3
(Diego)
September 24, 2007, 10:21pm
2
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