Class: Ability
- Inherits:
-
Object
- Object
- Ability
- Includes:
- CanCan::Ability
- Defined in:
- lib/generators/squeezer/templates/app/models/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.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/generators/squeezer/templates/app/models/ability.rb', line 4 def initialize(user) user ||= User.new # Guest user if (user.role?("Admin")) can :manage, :all else can :read, :all can :create, Post can :update, Post do |comment| comment.try(:user) == user end end end |