I have something that looks like this in my ability class
def initialize(staff)
staff ||= Staff.new
can :manage, Store do |store|
store.staff_privileges.select(&:owner?).map(&:staff_id).include? staff.id
end
end
I am not sure why staff.can? :manage
would return true here because I thought the above block should only get executed on the instance of store and not on the class itself
staff = Staff.first
staff.can? :manage, Store #true
staff.can? :manage, Store.first #false, because there is no staff_privileges associated to this store