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
<%= link_to "Upvote", {:controller =>"comments", :action => "upvote", :id => comment.id}, :class => 'btn', method: :put %>
<%= link_to "Downvote", {:controller =>"comments", :action => "downvote", :id => comment.id}, :class => 'btn', method: :put %>
in my routes.rb file
put '/comments/:id/:action' => 'comments#upvote'
put '/comments/:id/:action' => 'comments#downvote'
Then in my comments controller
class CommentsController < ApplicationController
before_filter :load_commentable
before_filter :find_comment, :only => [:upvote, :downvote]
def upvote
current_user.upvotes @comment
redirect_to(@comment.commentable)
end
def downvote
@comment.downvote_from current_user
redirect_to(@comment.commentable)
end
private
def load_commentable
resource, id = request.path.split('/')[1, 2]
@commentable = resource.singularize.classify.constantize.find(id)
end
def find_comment
@comment = Comment.find(@commentable.id)
end
end
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.