Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

refactor

  • Loading branch information...
commit 61826bcca3481a85649be714a91a45ca909f2726 1 parent 9abe098
@jonleighton jonleighton authored
Showing with 5 additions and 11 deletions.
  1. +5 −11 activerecord/lib/active_record/railtie.rb
View
16 activerecord/lib/active_record/railtie.rb
@@ -97,18 +97,12 @@ class Railtie < Rails::Railtie
end
initializer "active_record.set_reloader_hooks" do |app|
- hook = lambda do
- ActiveRecord::Base.clear_reloadable_connections!
- ActiveRecord::Base.clear_cache!
- end
+ hook = app.config.reload_classes_only_on_change ? :to_prepare : :to_cleanup
- 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)
+ ActiveSupport.on_load(:active_record) do
+ ActionDispatch::Reloader.send(hook) do
+ ActiveRecord::Base.clear_reloadable_connections!
+ ActiveRecord::Base.clear_cache!
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.