Skip to content

Instantly share code, notes, and snippets.

@didicodethat
Created January 26, 2017 14:46
Show Gist options
  • Save didicodethat/e63794a2cf3216808db12342a9dd145a to your computer and use it in GitHub Desktop.
Save didicodethat/e63794a2cf3216808db12342a9dd145a to your computer and use it in GitHub Desktop.
def authorize_mass_actions local_action
policy_name = if ['read_all', 'move_to_inbox', 'restore_messages'].include?(local_action)
:update?
else
:destroy?
end
Message.with_deleted.where(id: params[:messages_ids]).each do |message|
authorize(message, policy_name)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment