Class: FeatureBox::Ability
- Inherits:
-
Object
- Object
- FeatureBox::Ability
- Includes:
- CanCan::Ability
- Defined in:
- app/models/feature_box/ability.rb
Instance Method Summary collapse
-
#initialize(user) ⇒ Ability
constructor
A new instance of Ability.
Constructor Details
#initialize(user) ⇒ Ability
Returns a new instance of Ability.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/feature_box/ability.rb', line 6 def initialize(user) user ||= FeatureBox::User.new # guest user (not logged in) if user.admin? can :read, :all can :read_protected, :all # read_protected is for signed in users only can :create, :all can :update, :all can :destroy, :all elsif user.id # registered user can :read, [Suggestion, Comment] can :read_protected, [Suggestion, Comment] can :update, [Suggestion, Comment], :user_id => user.id can :destroy, [Suggestion, Comment], :user_id => user.id can :create, [Suggestion, Comment, Vote] else can :read, [Suggestion, Comment] end end |