module ActiveAdmin::BaseController::Authorization
Constants
- ACTIONS_DICTIONARY
Protected Instance Methods
Source
# File lib/active_admin/base_controller/authorization.rb, line 98 def action_to_permission(action) if action && action = action.to_sym Authorization::ACTIONS_DICTIONARY[action] || action end end
Converts a controller action into one of the correct Active Admin authorization names. Uses the ACTIONS_DICTIONARY
to convert the action name to permission.
@param [String, Symbol] action The controller action name.
@return [Symbol] The permission name to use.
Source
# File lib/active_admin/base_controller/authorization.rb, line 104 def dispatch_active_admin_access_denied(exception) instance_exec(self, exception, &active_admin_namespace.on_unauthorized_access.to_proc) end
Source
# File lib/active_admin/base_controller/authorization.rb, line 123 def redirect_backwards_or_to_root redirect_back fallback_location: active_admin_root end
Source
# File lib/active_admin/base_controller/authorization.rb, line 108 def rescue_active_admin_access_denied(exception) error = exception.message respond_to do |format| format.html do flash[:error] = error redirect_backwards_or_to_root end format.csv { render body: error, status: :unauthorized } format.json { render json: { error: error }, status: :unauthorized } format.xml { render xml: "<error>#{error}</error>", status: :unauthorized } end end