Rails thumbs_up error Validation failed: Voteable has already been taken
So thumbs_up does exactly what I want it to, but when I try to double vote I get this error Validation failed: Voteable has already been taken
instead of being redirected to the previous page and Im开发者_开发知识库 not sure how to do that
OK, I dont know if its supposed to redirect automatically like Vote_fu does but I fixed it by adding an if/else in the controller to see if the current user has voted on the item or not.
unless current_member.voted_for?(@tattoo)
current_member.vote_for(@tattoo)
redirect_to :back
else
redirect_to :back
end
精彩评论