Class: ActiveAdmin::CanCanAdapter

Inherits:
AuthorizationAdapter show all
Defined in:
lib/active_admin/cancan_adapter.rb

Instance Attribute Summary

Attributes inherited from AuthorizationAdapter

#resource, #user

Instance Method Summary collapse

Methods inherited from AuthorizationAdapter

#initialize

Constructor Details

This class inherits a constructor from ActiveAdmin::AuthorizationAdapter

Instance Method Details

#authorized?(action, subject = nil) ⇒ Boolean

Returns:

  • (Boolean)

14
15
16
# File 'lib/active_admin/cancan_adapter.rb', line 14

def authorized?(action, subject = nil)
  cancan_ability.can?(action, subject)
end

#cancan_abilityObject


18
19
20
# File 'lib/active_admin/cancan_adapter.rb', line 18

def cancan_ability
  @cancan_ability ||= initialize_cancan_ability
end

#scope_collection(collection, action = ActiveAdmin::Auth::READ) ⇒ Object


22
23
24
# File 'lib/active_admin/cancan_adapter.rb', line 22

def scope_collection(collection, action = ActiveAdmin::Auth::READ)
  collection.accessible_by(cancan_ability, action)
end