Created
January 9, 2014 23:42
-
-
Save dylanerichards/8344261 to your computer and use it in GitHub Desktop.
Acts as votable. Trying to make it so that users don't have to sign in to upvote/downvote.
This file contains hidden or 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 upvote | |
@guide = Guide.find(params[:id]) | |
@guide.liked_by current_user | |
redirect_to :back | |
end | |
def downvote | |
@guide = Guide.find(params[:id]) | |
@guide.downvote_from current_user | |
redirect_to :back | |
end |
This file contains hidden or 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
resources :guides do | |
member do | |
put "like", to: "guides#upvote" | |
put "dislike", to: "guides#downvote" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment