This project is archived and is in readonly mode.
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:
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.
Comments and changes to this ticket
-
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 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 ?
Thanks.
-
Pratik May 18th, 2009 @ 09:42 PM
- Assigned user changed from Pratik to Michael Koziarski
- State changed from new to stale
-
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.
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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 1083 Calls to private methods via association proxies should act consistently with Ruby method dispatch I've submitted a fix for this problem in this ticket. Ho...
- 1642 HasOneThroughAssociation should not be a child of HasManyThroughAssociation 4) This patch makes HasOneThroughAssociation a peer of Ha...