views:

266

answers:

1

I have this line in routes:

map.resources :questions, :new => {:vote_for => :put, :vote_against => :put}, :has_many => :replies, :shallow => true
And I use the following helpers in my view:
link_to 'OK', vote_for_question_path(@question), :method => :put
link_to 'NO', vote_against_question_path(@question), :method => :put

But unfortunately there is something wrong with my code, as Rails says:

undefined method `vote_for_question_path' for #

What's wrong?

+2  A: 
John Topley
Thanks, it works! I'd like to use the RESTful conventions (as you suggested), but I have no idea how to specify whether the vote is +1 or -1 using /questions/22/votes/new :(
collimarco
It's difficult to give you guidance without knowing more about your application. The general idea is that your Question model would be associated with the Vote model, which would probably be associated with a User model. When I user voted on a question, that Vote instance would be added to the collection of Votes for that Question. For a -1 it would be removed.
John Topley