module ActiveAdmin::BaseController::Authorization
Constants
- ACTIONS_DICTIONARY
Protected Instance Methods
action_to_permission(action)
click to toggle source
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.
@returns [Symbol] The permission name to use.
# File lib/active_admin/base_controller/authorization.rb, line 114 def action_to_permission(action) return nil unless action action = action.to_sym if Authorization::ACTIONS_DICTIONARY.has_key?(action) Authorization::ACTIONS_DICTIONARY[action] else action end end
dispatch_active_admin_access_denied(exception)
click to toggle source
# File lib/active_admin/base_controller/authorization.rb, line 126 def dispatch_active_admin_access_denied(exception) call_method_or_exec_proc active_admin_namespace.on_unauthorized_access, exception end
rescue_active_admin_access_denied(exception)
click to toggle source
# File lib/active_admin/base_controller/authorization.rb, line 130 def rescue_active_admin_access_denied(exception) error_message = exception.message respond_to do |format| format.html do flash[:error] = error_message if request.headers.key?("HTTP_REFERER") redirect_to :back else controller, action = active_admin_namespace.root_to.split("#") redirect_to :controller => controller, :action => action end end format.csv { render :text => error_message, :status => :unauthorized} format.json { render :json => { :error => error_message }, :status => :unauthorized} format.xml { render :xml => "<error>#{error_message}</error>", :status => :unauthorized} end end