Created
October 25, 2011 21:08
-
-
Save davelnewton/1314284 to your computer and use it in GitHub Desktop.
Quick voting refactoring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Author
davelnewton
commented
Oct 25, 2011
via email
I'm just a guy that enjoys programming, and helping other people enjoy it :)
Dave
…On Tue, Oct 25, 2011 at 7:42 PM, Raphael Caldas < ***@***.***>wrote:
You're an amazing guy. Thanks a lot for putting this effort in helping out
a stranger. Whenever I can do anything for you, please just ask.
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/1314284
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment