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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With