diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2010-09-01 15:09:04 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-09-01 22:32:41 +0200 |
commit | 4e67bf26aa11a59e4f513359208fe3314c5a1ba5 (patch) | |
tree | fe85848facd45aa82627651dce257831339a4e74 /activerecord/lib | |
parent | f1966337fa744a1c62054120693072ebabe996a8 (diff) | |
download | rails-4e67bf26aa11a59e4f513359208fe3314c5a1ba5.tar.gz rails-4e67bf26aa11a59e4f513359208fe3314c5a1ba5.tar.bz2 rails-4e67bf26aa11a59e4f513359208fe3314c5a1ba5.zip |
Reset default scope in Thread.current when class is unloaded [#5497 state:resolved]
Signed-off-by: Xavier Noria <fxn@hashref.com>
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index f465a38dbe..c3a34ae104 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -890,6 +890,10 @@ module ActiveRecord #:nodoc: Thread.current[key] = Thread.current[key].presence || self.default_scoping.dup end + def before_remove_const #:nodoc: + reset_scoped_methods + end + private def relation #:nodoc: @@ -1174,6 +1178,10 @@ MSG scoped_methods.last end + def reset_scoped_methods #:nodoc: + Thread.current[:"#{self}_scoped_methods"] = nil + end + # Returns the class type of the record using the current module as a prefix. So descendants of # MyApp::Business::Account would appear as MyApp::Business::AccountSubclass. def compute_type(type_name) |