Nich
Nich

Reputation: 1102

CanCan Defining ability

Is there a way not to define equal ? but includes?

can :read, Project, :category => { :visible => true }

can :read, Project, :category => { :map(&:user_id) => { include(user.id) } }

Using CanCan and ruby on rails...

Thanks

Upvotes: 0

Views: 75

Answers (1)

cortex
cortex

Reputation: 5206

I don't understand what exactly you want to accomplish. Based on @apneadiving comment you can do something like:

can :read, Project do |project|
  project.category.user_ids.include?(user.id)
end

For more information read this section of CanCan wiki.

Upvotes: 1

Related Questions