pundit: convert comment votes to pundit.
This commit is contained in:
@@ -1,23 +1,22 @@
|
|||||||
class CommentVotesController < ApplicationController
|
class CommentVotesController < ApplicationController
|
||||||
before_action :member_only, except: [:index]
|
|
||||||
skip_before_action :api_check
|
skip_before_action :api_check
|
||||||
respond_to :js, :json, :xml, :html
|
respond_to :js, :json, :xml, :html
|
||||||
rescue_with CommentVote::Error, ActiveRecord::RecordInvalid, status: 422
|
rescue_with CommentVote::Error, ActiveRecord::RecordInvalid, status: 422
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@comment_votes = CommentVote.visible(CurrentUser.user).paginated_search(params, count_pages: true)
|
@comment_votes = authorize CommentVote.visible(CurrentUser.user).paginated_search(params, count_pages: true)
|
||||||
@comment_votes = @comment_votes.includes(:user, comment: [:creator, post: [:uploader]]) if request.format.html?
|
@comment_votes = @comment_votes.includes(:user, comment: [:creator, post: [:uploader]]) if request.format.html?
|
||||||
respond_with(@comment_votes)
|
respond_with(@comment_votes)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@comment = Comment.find(params[:comment_id])
|
@comment = authorize Comment.find(params[:comment_id])
|
||||||
@comment_vote = @comment.vote!(params[:score])
|
@comment_vote = @comment.vote!(params[:score])
|
||||||
respond_with(@comment)
|
respond_with(@comment)
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@comment = Comment.find(params[:comment_id])
|
@comment = authorize Comment.find(params[:comment_id])
|
||||||
@comment.unvote!
|
@comment.unvote!
|
||||||
respond_with(@comment)
|
respond_with(@comment)
|
||||||
end
|
end
|
||||||
|
|||||||
2
app/policies/comment_vote_policy.rb
Normal file
2
app/policies/comment_vote_policy.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
class CommentVotePolicy < ApplicationPolicy
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user