tap/app/models/ability.rb

18 lines
343 B
Ruby
Raw Normal View History

2014-12-09 18:44:58 +00:00
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
2014-12-09 18:44:58 +00:00
if user.admin?
can :manage, :all
2015-01-06 19:18:01 +00:00
elsif user.koelkast?
can :manage, Order
2015-02-10 06:15:25 +00:00
elsif user[:id]
2014-12-09 18:44:58 +00:00
can :read, :all
can :manage, User, id: user.id
can :manage, Order, user: user
2014-12-09 18:44:58 +00:00
end
end
end