Vince W
Vince W

Reputation: 171

Trying to find the opposite of this cancan ability

I've got a cancan ability that works but I'm looking to get the opposite effect:

can :block, Company, id: user.company_id

here's what I've tried:

can :block, Company, id: !user.company_id
cannot :block, Company, id: user.company_id
cannot :block, Company, :id => user.company_id
can :block, Company, :id => !user.company_id

And none work at all. Can somebody help me define the correct ability?

Upvotes: 0

Views: 56

Answers (1)

Eric K
Eric K

Reputation: 395

How about this?

can :block, Company do |company|
  company.id != user.company_id
end

Upvotes: 1

Related Questions