Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bchadfield
Created October 31, 2014 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bchadfield/8b19b55d03b362ee4220 to your computer and use it in GitHub Desktop.
Save bchadfield/8b19b55d03b362ee4220 to your computer and use it in GitHub Desktop.
<%= link_to "Upvote", vote_polls_path(poll, :vote_type => "upvotes"), :remote => true %>
<%= link_to "Downvote", vote_polls_path(poll, :vote_type => "downvotes"), :remote => true %>
# Add :vote to your set_poll before_action
def vote
@poll.increment!(params[:vote_type].to_sym) if ["upvotes", "downvotes"].include?(params[:vote_type])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment