Reputation: 42380
I have a stories controller that i have mapped as a resource. I've added 2 new methods to stories_controller, 'top' and 'latest'. but when i try to go to example.com/stories/top I get a 'no story with ID=top' error. How can I change the routing to recognize these urls?
Upvotes: 15
Views: 8905
Reputation: 65517
Try in Rails 2.x:
map.resources :stories, :collection => { :top => :get , :latest => :get }
In Rails 3.x:
resources :stories do
collection do
get 'top'
get 'latest'
end
end
Upvotes: 33