pundit: convert post disapprovals to pundit.

This commit is contained in:
evazion
2020-03-19 20:10:48 -05:00
parent 84c654464d
commit ba0a5dda8a
5 changed files with 42 additions and 32 deletions

View File

@@ -1,23 +1,17 @@
class PostDisapprovalsController < ApplicationController
before_action :approver_only, only: [:create]
skip_before_action :api_check
respond_to :js, :html, :json, :xml
def create
@post_disapproval = PostDisapproval.create(user: CurrentUser.user, **post_disapproval_params)
@post_disapproval = authorize PostDisapproval.new(user: CurrentUser.user, **permitted_attributes(PostDisapproval))
@post_disapproval.save
respond_with(@post_disapproval)
end
def index
@post_disapprovals = PostDisapproval.paginated_search(params)
@post_disapprovals = authorize PostDisapproval.paginated_search(params)
@post_disapprovals = @post_disapprovals.includes(:user) if request.format.html?
respond_with(@post_disapprovals)
end
private
def post_disapproval_params
params.require(:post_disapproval).permit(%i[post_id reason message])
end
end