Module: AbilityHelper

Defined in:
app/helpers/ability_helper.rb

Defined Under Namespace

Classes: UserCantReceiveAbilityError

Instance Method Summary collapse

Instance Method Details

#able(user, ability_str, module_str) ⇒ Object



7
8
9
10
11
12
13
# File 'app/helpers/ability_helper.rb', line 7

def able(user, ability_str, module_str)
  ability_model = SystemAbility.find_by_name(ability_str.to_s.upcase)
  module_model = SystemModule.find_by_name(module_str.to_s.camelize)
  raise UserCantReceiveAbilityError.new "system ability dont exists %s." % ability_str if (ability_model==nil)
  raise UserCantReceiveAbilityError.new "system module dont exists. %s" % module_str if (module_model==nil)
  user.abilities.build(:module => module_model, :ability => ability_model).save
end