I am unable to debug some of cancancan code and looking for some help.
can :update, Message do |m|
false
end
But strangely cancancan always return true and i am unable to debug the issue.Here is a small piece of relevant cancancan code
rule.rb
def matches_conditions?(action, subject, extra_args)
if
...
elsif @block && !subject_class?(subject)
@block.call(subject, *extra_args)
end
end
I can see that the @block.call is made and it return false but this piece of code in the ability.rb does not make sense to me
match = subject.map do |subject|
relevant_rules_for_match(action, subject).detect do |rule|
rule.matches_conditions?(action, subject, extra_args)
end
end.compact.first
match ? match.base_behavior : false
The base_behaviour is never set after initialization, and set to true at initialization, how would base_behaviour of a rule would ever return false.
The helper function is called
ability = Ability.new(user)
ability.can? :update ,@message