Susan Cosentino

Joined

10 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in CanCanCan: Defining Abilities

Hello,
To limit access to records in CanCanCan based on a condition like the brand column being nil, you can use a block to define the conditions for the ability. Here's how you can set it up:

ruby
class Ability
include CanCan::Ability

def initialize(user)
can :crud, Order, brand: nil
end
end

In this example, the can method is using a hash to specify that the brand column must be nil for users to have :crud access to Order records.