Created
July 24, 2012 04:54
-
-
Save abutcher/3168104 to your computer and use it in GitHub Desktop.
Some votestuff
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 | |
| @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 | |
| ... |
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
| <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 %> |
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
| match ':controller(/:action(/:id(.:format)))' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment