Method: CanCan::Ability#cannot

Defined in:
lib/cancan/ability.rb

#cannot(action = nil, subject = nil, *attributes_and_conditions, &block) ⇒ Object

Defines an ability which cannot be done. Accepts the same arguments as “can”.

can :read, :all
cannot :read, Comment

A block can be passed just like “can”, however if the logic is complex it is recommended to use the “can” method.

cannot :read, Product do |product|
  product.invisible?
end


160
161
162
# File 'lib/cancan/ability.rb', line 160

def cannot(action = nil, subject = nil, *attributes_and_conditions, &block)
  add_rule(Rule.new(false, action, subject, *attributes_and_conditions, &block))
end