Class: Ability
- Inherits:
-
Object
- Object
- Ability
- Includes:
- CanCan::Ability
- Defined in:
- app/models/ability.rb
Instance Method Summary collapse
-
#initialize(user) ⇒ Ability
constructor
commented code is left for example for hostapps.
- #restricted_features_for_admin ⇒ Object
Constructor Details
#initialize(user) ⇒ Ability
commented code is left for example for hostapps. In hostapp developer can override this class for custom authorization requirements
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/ability.rb', line 5 def initialize(user) user ||= User.new # guest user (not logged in) if user.super_admin? can :manage, :all elsif user.admin? can :manage, :all restricted_features_for_admin else can :manage, :all restricted_features_for_admin cannot :manage , User cannot :manage , Gluttonberg::Setting cannot :destroy , Gluttonberg::Asset #page roles #cannot :manage , Gluttonberg::Page cannot :change_home , Gluttonberg::Page cannot :destroy , Gluttonberg::Page cannot :publish , Gluttonberg::Page cannot :reorder , Gluttonberg::Page #cannot :manage , Gluttonberg::Blog cannot :publish , Gluttonberg::Blog cannot :destroy , Gluttonberg::Blog #cannot :manage , Gluttonberg::Article #cannot :publish , Gluttonberg::Article #cannot :destroy , Gluttonberg::Article #cannot :manage , Gluttonberg::Comment #cannot :moderate , Gluttonberg::Comment end end |
Instance Method Details
#restricted_features_for_admin ⇒ Object
42 43 44 45 |
# File 'app/models/ability.rb', line 42 def restricted_features_for_admin cannot :manage , Gluttonberg::Locale cannot :create_or_destroy , Gluttonberg::Setting end |