Skip to content

Instantly share code, notes, and snippets.

@abutcher
Created July 24, 2012 04:54
Show Gist options
  • Select an option

  • Save abutcher/3168104 to your computer and use it in GitHub Desktop.

Select an option

Save abutcher/3168104 to your computer and use it in GitHub Desktop.
Some votestuff
...
def upvote
@tweet = Tweet.find(params[:tweet_id])
@tweet.goodvotes = @tweet.goodvotes + 1
@tweet.save
redirect_to :root
end
def downvote
@tweet = Tweet.find(params[:tweet_id])
@tweet.badvotes = @tweet.badvotes + 1
@tweet.save
redirect_to :root
end
...
<p>
<b>Author:</b>
<%= @tweet.author %>
</p>
<p>
<b>Content:</b>
<%= @tweet.content %>
</p>
<%= form_tag({:controller => "tweets", :action => "upvote"}, :method => "post") do %>
<%= hidden_field_tag :tweet_id, @tweet.id %>
<%= submit_tag("This is legitimate fact.") %>
<% end %>
<%= form_tag({:controller => "tweets", :action => "downvote"}, :method => "post") do %>
<%= hidden_field_tag :tweet_id, @tweet.id %>
<%= submit_tag("This is horse shit.") %>
<% end %>
<%= link_to 'Edit', edit_tweet_path(@tweet) %> |
<%= link_to 'Back', tweets_path %>
match ':controller(/:action(/:id(.:format)))'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment