Module: CanCanCan::Extensions::Ability

Defined in:
lib/cancancan/extensions/ability.rb

Overview

orverwriting .relevant_rules_for_match method from CanCan::Ability module

Instance Method Summary collapse

Instance Method Details

#relevant_rules_for_match(action, subject) ⇒ Object

original method, to want to make scope work with rule like “can :read, Article, Article.where(secret: true)”, we are skipping raising of error in case of rule being raw query def relevant_rules_for_match(action, subject)

relevant_rules(action, subject).each do |rule|
  next unless rule.only_raw_sql?
  raise Error,
        "The can? and cannot? call cannot be used with a raw sql."
end

end



15
16
17
# File 'lib/cancancan/extensions/ability.rb', line 15

def relevant_rules_for_match(action, subject)
  relevant_rules(action, subject)
end