Problem with rails routing
I have the following in my routing config:
开发者_C百科resources :users do
resources :apps, :controller => :user_apps
end
rake routes
includes the following:
user_apps GET /users/:user_id/apps(.:format) {:action=>"index", :controller=>"user_apps"}
user_apps POST /users/:user_id/apps(.:format) {:action=>"create", :controller=>"user_apps"}
new_user_app GET /users/:user_id/apps/new(.:format) {:action=>"new", :controller=>"user_apps"}
edit_user_app GET /users/:user_id/apps/:id/edit(.:format) {:action=>"edit", :controller=>"user_apps"}
user_app GET /users/:user_id/apps/:id(.:format) {:action=>"show", :controller=>"user_apps"}
user_app PUT /users/:user_id/apps/:id(.:format) {:action=>"update", :controller=>"user_apps"}
user_app DELETE /users/:user_id/apps/:id(.:format) {:action=>"destroy", :controller=>"user_apps"}
However, when I try to access eg user_apps_path(1,2)
I get /users/1/apps.2
rather than /users/1/apps/2
.
Where am I going wrong?
I'm using rails 3.
The correct route is user_app_path(1,2)
The pluralized version goes to the index
action, making the second argument the format / extension of the request.
精彩评论