Skip to content

Instantly share code, notes, and snippets.

@dylanerichards
Created January 9, 2014 23:42
Show Gist options
  • Save dylanerichards/8344261 to your computer and use it in GitHub Desktop.
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.
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
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