This project is archived and is in readonly mode.
New "scoped" implementation since v2.3.9 breaks chained scopes with custom methods
Reported by Logan Bowers | November 3rd, 2010 @ 11:34 PM
Using git-bisect, I tracked down an issued to commit bfbdeea,
"Use bind instead of instance_exec cause it may be causing memory
leaks. Also, provide a simpler and sane implementation for
scoped.". This commit changes how scoped works such that it no
longer propagates custom methods on scopes.
This is an example of the broken case:
class MyModel < ActiveRecord::Base
has_many :widgets do
def limited_to(x)
scoped(:conditions => ...)
end
def fnord
"a fnord"
end
end
end
class Widget < ActiveRecord::Base
end
MyModel.find(:first).widgets.limited_to(true).fnord # <- EXPLODES undefined method 'fnord' for #<Class:...>
I'm not sure exactly how the scoping functionality changed with this commit, but it broke this case.
Comments and changes to this ticket
-
Logan Bowers November 3rd, 2010 @ 11:35 PM
- Assigned user set to José Valim
-
Logan Bowers November 3rd, 2010 @ 11:43 PM
- Tag set to bug, regression
-
José Valim November 4th, 2010 @ 12:17 AM
- State changed from resolved to open
- Importance changed from to Low
This is the commit hash: https://github.com/rails/rails/commit/bfbdeeae3080c89a0b27e42d684cb...
I am a bit busy this week, but I will try to find sometime to take a look at it next one.
-
James Le Cuirot November 4th, 2010 @ 10:45 AM
Interesting. I tried this on an app of mine and it worked. But that app has a fair few modifications to Rails. I switched to vanilla and it failed as you've showed. I'll try to find out what I've done that fixes it. This probably goes without saying but I recommend you don't revert that old commit, even temporarily, the memory leak was massive.
-
Neeraj Singh November 4th, 2010 @ 07:28 PM
Attached is patch with test for 2-3-stable. Needless to say all the tests are passing with the patch.
-
Neeraj Singh November 4th, 2010 @ 07:32 PM
For the last couple of days I am not able to upload any attachment. Not sure what happend. Is it LH issue or is it my browser. Next time I will try FF.
In the meantime the attachment is on dropbox. Sorry about this. I will try FF and if that does not work I will report and issue to entp.
-
Santiago Pastorino February 5th, 2011 @ 08:56 PM
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino February 5th, 2011 @ 08:56 PM
- State changed from open to stale
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
Tags
Referenced by
- 5044 Recent named_scope STI fix causes a massive slow down and memory leak This commit regressed scoped() functionality, please see ...