diff options
author | José Valim <jose.valim@gmail.com> | 2011-12-15 18:48:10 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-12-15 18:48:10 +0100 |
commit | 283a08763495a6b3ce0b196259ee1666f2b08cf1 (patch) | |
tree | efd3899d1a822658a7c5c835d6198ea506a71148 /activerecord | |
parent | de947c621d8ee18caca574451c722a6e30c4e6d6 (diff) | |
download | rails-283a08763495a6b3ce0b196259ee1666f2b08cf1.tar.gz rails-283a08763495a6b3ce0b196259ee1666f2b08cf1.tar.bz2 rails-283a08763495a6b3ce0b196259ee1666f2b08cf1.zip |
Clean up the cache before the request in case we are running in the reload_classes_only_on_change schema.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/railtie.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index b28e8da24c..08cf9fb504 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -85,11 +85,19 @@ module ActiveRecord end end - initializer "active_record.set_dispatch_hooks", :before => :set_clear_dependencies_hook do |app| - ActiveSupport.on_load(:active_record) do - ActionDispatch::Reloader.to_cleanup do - ActiveRecord::Base.clear_reloadable_connections! - ActiveRecord::Base.clear_cache! + initializer "active_record.set_reloader_hooks" do |app| + hook = lambda do + ActiveRecord::Base.clear_reloadable_connections! + ActiveRecord::Base.clear_cache! + end + + if app.config.reload_classes_only_on_change + ActiveSupport.on_load(:active_record) do + ActionDispatch::Reloader.to_prepare(&hook) + end + else + ActiveSupport.on_load(:active_record) do + ActionDispatch::Reloader.to_cleanup(&hook) end end end |