Reputation: 3187
I have the following routes, which allows for urls like /:username/:project_name
resources :users, :path => "/" do
resources :projects, :path => "/"
end
The problem is that /:username/edit
doesn't work, because it is looking for a project with the name of 'edit'.
Any way around this? Thanks!
Upvotes: 2
Views: 1260
Reputation: 46713
A couple ways of doing this...
1) Will give you routes like /:user_id/:id
(which you wanted)
match '/:user_id/edit', :to => 'users#edit', :as => :edit_user
resources :users, :except => [:edit], :path => "/" do
resources :projects, :path => "/"
end
2) Will give you routes like /:user_id/projects/:id
(which it seems like you're avoiding)
resources :users, :path => "/" do
resources :projects
end
I personally prefer #2 since it is cleaner and provides more knowledge about the route at a glance.
Upvotes: 3