I’m trying develop a reddit style site which allows users to vote on links. The voting feature goes beyond basic CRUD supported by resources :links I’ve written the up/down actions and linked them to the view but I’m not sure how to handle routing. Could someone demonstrate how I would route to custom controller actions? I’ve attached my files below. Thanks
I receive this error when I load the view
No route matches {:controller=>"links", :action=>"up"}
Links Controller https://gist.github.com/1272577
You can extend
resourcesmapping with this example:These actions must be available in LinksController class (same as new, create…).
More in Ruby on Rails Guide: Rails Routing.
Tip: actions changing state of entity should not use GET verb. This is because search bots or accelerator may follow your voting links.
You link should be:
And in controller should modify your entinty only inside
if request.post?. You should still support GET to not cause 404s.