This project is archived and is in readonly mode.

#5488 ✓resolved
Jan Xie

default_scope doesn't work at a late point

Reported by Jan Xie | August 29th, 2010 @ 04:19 AM

I think there may be a problem with this line:

http://github.com/rails/rails/blob/master/activerecord/lib/active_r...

If scoped_methods invoked at an early point, and you use default_scope to (create a new)/(update existing) default scope later, all current_scoped_methods depending finders (like #all) will still use the old default_scope, because the thread cache is not cleared.

I got this problem when I try to update default scope in my plugin, I need to set Thread.current[key] to nil myself whenever I set a new default scope.

Comments and changes to this ticket

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>

Attachments

Referenced by

Pages