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)


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

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

#cancan_abilityObject



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

def cancan_ability
  @cancan_ability ||= initialize_cancan_ability
end

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



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

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