Files
danbooru/app/controllers/comment_votes_controller.rb
2017-01-16 12:57:43 -08:00

22 lines
530 B
Ruby

class CommentVotesController < ApplicationController
respond_to :js, :json, :xml
before_filter :member_only
skip_before_filter :api_check
def create
@comment = Comment.find(params[:comment_id])
@comment_vote = @comment.vote!(params[:score])
rescue CommentVote::Error, ActiveRecord::RecordInvalid => x
@error = x
render status: 500
end
def destroy
@comment = Comment.find(params[:comment_id])
@comment.unvote!
rescue CommentVote::Error => x
@error = x
render status: 500
end
end