I currently have a comment controller that has the method vote_up and vote_down this is how my vote_up currently works.
My Comment model has description and a count field.
def vote_up
@comment = Comment.find(params[:comment_id])
@comment.count += 1
if @comment.save
flash[:notice] = "Thank you for voting"
respond_to do |format|
format.html { redirect_to show_question_path(@comment.question) }
format.js
end
else
flash[:notice] = "Error Voting Please Try Again"
redirect_to show_question_path(@comment.question)
end
end
This allows for multiple vote up and downs. How would I design it so that a user can only vote once per comment but somehow keep track if they voted up or down, so they have the ability to change their vote if they want too.