This project is archived and is in readonly mode.

#1643 ✓wontfix
Adam Milligan

Association proxies should correctly respond to method defined via #method_missing

Reported by Adam Milligan | December 27th, 2008 @ 08:22 AM | in 2.x

This patch: 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: . This is because the HasOneThroughAssociation < HasManyThroughAssociation subclass relationship imported unnecessary collection-specific behavior into the has_one :through association.

Comments and changes to this ticket

  • Adam Milligan

    Adam Milligan December 28th, 2008 @ 01:50 AM

    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.

  • Pratik

    Pratik March 8th, 2009 @ 02:37 PM

    • 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 ?


  • Pratik

    Pratik May 18th, 2009 @ 09:42 PM

    • Assigned user changed from “Pratik” to “Michael Koziarski”
    • State changed from “new” to “stale”
  • Michael Koziarski

    Michael Koziarski May 18th, 2009 @ 10:35 PM

    • 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.

  • klkk

    klkk May 23rd, 2011 @ 03:00 AM

    • Importance changed from “” to “”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>


Referenced by