I installed the acts_as_votable gem, it works in the console like it should (like it says in the documentation). So my question is how to set up a form for upvote and downvote buttons? or can they simply be links?
here is the documentation: github.com/ryanto/acts_as_votable/blob/master/README.markdown
I have a user and a picture model; the user is supposed to be able to like the picture. code from the picture view, where the buttons should be:
<% for picture in @pictures %>
<p>
<%= image_tag picture.image_url(:thumb).to_s %>
</p>
<%= picture.created_at.strftime("%a, %d %b. %Y") %>, by
<%= link_to picture.user.name, picture.user %>
<h2> <%= link_to picture.name, picture %></h2>
[buttons here]
<%= picture.votes.size %> <% end %>
thanks in advance!
Here's how I ended up doing it with the acts_as_commentable gem too. So I think this should work with any object that you have comments for.
In my _comment.html.erb view
in my routes.rb file
Then in my comments controller
The before filters allow for more versatility so I can add this to any commentable object. Mine happened to be festivals, but you could do pictures or anything really. Check out the acts_as_commentable documentation and the polymorphic railscast for more information on that. This is my first post so if this is terrible code, just tell me.
One way to do this is to add your own controller actions for up- and downvotes. I'm assuming you have a
current_user
method available in your controller.