Module: Alchemy::AbilityHelper
- Included in:
- BaseController
- Defined in:
- lib/alchemy/ability_helper.rb
Instance Method Summary collapse
-
#current_ability ⇒ Object
Ensures usage of Alchemy’s permissions class.
Instance Method Details
#current_ability ⇒ Object
Ensures usage of Alchemy’s permissions class.
Register custom Abilities
If your app has a CanCan Ability class with rules you want to be aviable in an Alchemy context you need to register it. Or if you have an engine with it’s own CanCan abilities you want to add to Alchemy you must register them first.
Alchemy.register_ability MyCustom::Permisson
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/alchemy/ability_helper.rb', line 12 def current_ability @current_ability ||= begin = Alchemy::Permissions.new(current_alchemy_user) Alchemy.registered_abilities.each do |klass| # Ensure to avoid issues with Rails constant lookup. klass = "::#{klass}".constantize .merge(klass.new(current_alchemy_user)) end end end |