controller_path(object) is returning website.com/controller.1
I have manually created a new View for an existing scaffolded Model in my Rails app because, well I thought that was the point, I can create multiple views for the same Model. Everything seems to function fine except that when I try to link_to an item in the view then Rails gives me the wrong URL.
- routes.rb has the proper "resources :controller"
- controller_controller.rb exists and works fine
- views/controller/show.html.erb exists and works fine
- link_to "controller", controller_path #works fine
link_to "controller", controller_path(object) # links to controller but adds the id as ".id" instead of "/id"
Any ideas why?
rake routes output
pups GET /开发者_高级运维pups(.:format) {:action=>"index", :controller=>"pups"}
POST /pups(.:format) {:action=>"create", :controller=>"pups"}
new_pup GET /pups/new(.:format) {:action=>"new", :controller=>"pups"}
edit_pup GET /pups/:id/edit(.:format) {:action=>"edit", :controller=>"pups"}
pup GET /pups/:id(.:format) {:action=>"show", :controller=>"pups"}
PUT /pups/:id(.:format) {:action=>"update", :controller=>"pups"}
DELETE /pups/:id(.:format) {:action=>"destroy", :controller=>"pups"}
Make sure your link_to is using pup_path(object)
and not pups_path(object)
(plural).
精彩评论