Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Association proxies should correctly respond to method defined via #method_missing

#1643

This patch: http://rails.lighthouseapp.com/p... changed association proxies so they will not respond to private methods. However, they also now will not respond to methods defined via #method_missing, since #respond_to? cannot return true for these methods.

This new patch changes this so that proxies will respond to methods defined via #method_missing. Tests included.

Note that this patch will produce a failing test unless applied after this patch: http://rails.lighthouseapp.com/p... . This is because the HasOneThroughAssociation < HasManyThroughAssociation subclass relationship imported unnecessary collection-specific behavior into the has_one :through association.

Reported by Adam Milligan · December 27th, 2008 @ 08:22 AM

State: wontfix
Milestone: 2.x
Assigned to: Michael Koziarski Michael Koziarski
Importance: none

Activity

  1. Adam Milligan
    Adam Milligan

    A fairly trivial amount of investigation made clear that #include? isn't going to cut it, performance-wise. Here is a new patch with a small change. Basically, I introduced a #respond_to? condition into the privacy check; this should short-circuit the conditional expression the vast majority of the time. Only the small remainder of calls will execute the #include? condition as well.

    December 28th, 2008 @ 01:50 AM

  2. Pratik
    Pratik
    • Assigned user set to Pratik

    If someone is manually overriding method_missing(), they should also be overriding respond_to?() to match the behaviour of method_missing. I imagine that would solve the problem ?

    Thanks.

    March 8th, 2009 @ 02:37 PM

  3. Pratik
    Pratik
    • Assigned user changed from Pratik to Michael Koziarski
    • State changed from new to stale

    May 18th, 2009 @ 09:42 PM

  4. Michael Koziarski
    Michael Koziarski
    • State changed from stale to wontfix

    if you override method_missing you must also override respond_to? otherwise you'll have this problem.

    Ditto any other code which checks respond_to? before sending a method.

    May 18th, 2009 @ 10:35 PM