Hi Daniele,
This error sounds to me like an old bug that I thought I had squashed! It is due to the CanCan compatible rules array being generated, having not been flattened.
It is supposed to end up as a one dimensional array of rules, but for some reason it ends up with some array entries still in the form of Rule arrays, hence CanCan
in
def relevant_rules(action, subject)
rules.reverse.select do |rule|
rule.expanded_actions = expand_actions(rule.actions)
rule.relevant? action, subject
end
end
Tries to do rule.actions, expecting the rule to be a CanCan Rule, but operates instead on an Array. I think the error is in CanTango::Ability::Executor
def execute!
return if !valid?
start_execute
return cached_rules if cached? && cached_rules?
clear_rules!
permit_rules
cache_rules! if cached?
end_execute
rules
end
Try perhaps instead returning
rules.flatten
From the paste error:
from /Users/xx/.rvm/gems/ruby-1.9.2-p290@test/gems/cantango-0.9.4.7/lib/cantango/users/user.rb:14:in `can?'
def can? *args
CanTango::Ability.new(active_account).can?(*args)
end
So it created a new CanTango::Ability, using the active_account (or the user itself as candidate) and then attempts to call can? (from CanCan::Ability)
can? expects there to be a #rules method which returns the array of rules
I think you could just patch CanTango::Ability with
def rules
@rules.flatten.compact
end
and it should work.
Let me know how it works for you. I have been spending most of my latest efforts on a total redesign of the whole framework…
Kristian