Allow undo votes in comments votes component
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
module Comments
|
||||
class VotesController < ApplicationController
|
||||
load_and_authorize_resource :comment
|
||||
before_action :authenticate_user!
|
||||
load_and_authorize_resource :comment
|
||||
load_and_authorize_resource through: :comment, through_association: :votes_for, only: :destroy
|
||||
before_action :verify_comments_open!
|
||||
|
||||
def create
|
||||
@@ -13,6 +14,14 @@ module Comments
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@comment.unvote_by(current_user)
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render :show }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def verify_comments_open!
|
||||
|
||||
Reference in New Issue
Block a user