Skip to content

Instantly share code, notes, and snippets.

@davelnewton
Created October 25, 2011 21:08
Show Gist options
  • Save davelnewton/1314284 to your computer and use it in GitHub Desktop.
Save davelnewton/1314284 to your computer and use it in GitHub Desktop.
Quick voting refactoring
def vote_yes
vote(:up_vote)
end
def vote_no
vote(:down_vote)
end
private
def vote(up_or_down)
@project = Project.find(params[:id])
current_user.send(up_or_down, @project)
flash[:success] = 'Thanks for voting!'
rescue MakeVoteable::Exceptions::AlreadyVotedError
flash[:error] = 'You already voted!'
end
redirect_to @project
@davelnewton
Copy link
Author

davelnewton commented Oct 25, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment