There indeed is an issue. It has to do with trying to call any
methods provided by the Identity module on an association. In
Rails2.2 they enforce visibility(public/private) on association_proxy
proxy_target's. What this does is prevent the method_missing(if
implemented) from being called on the proxy_target. The workaround(or
solution, whichever), according to Michael Koziarski in this ticket:
http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1083-calls-to-private-methods-via-association-proxies-should-act-consistently-with-ruby-method-dispatch#ticket-1083-22
is that if you implement method_missing, you should implement
respond_to? as well. I kind of agree with this, but it should be
advertised better in the association_proxy documentation.
If anyone has trouble, stick the code at the bottom in identity.rb
after method_missing. I don't have the time right now to get gel'in
with github, otherwise I'd commit it myself. Hopefully, someone else
can take the lead though.
def respond_to?(method_name)
method_name = method_name.to_s
base_regex = "is_(\\w+)"
fancy_regex = base_regex + "_(#
{Authorization::Base::VALID_PREPOSITIONS_PATTERN})"
is_either_regex = '^((' + fancy_regex + ')|(' + base_regex +
'))'
base_not_regex = "is_no[t]?_(\\w+)"
fancy_not_regex = base_not_regex + "_(#
{Authorization::Base::VALID_PREPOSITIONS_PATTERN})"
is_not_either_regex = '^((' + fancy_not_regex + ')|(' +
base_not_regex + '))'
if method_name =~ Regexp.new(is_either_regex + '_what$')
return true
elsif method_name =~ Regexp.new(is_not_either_regex + '\?$')
return true
elsif method_name =~ Regexp.new(is_either_regex + '\?$')
return true
elsif method_name =~ Regexp.new(is_not_either_regex + '$')
return true
elsif method_name =~ Regexp.new(is_either_regex + '$')
return true
else
return super
end
end