diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-07-01 17:59:43 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-07-01 17:59:43 -0700 |
commit | 9d599abe0febd96d7cd1f22e7d5f380187ae4476 (patch) | |
tree | 98af019938a39ab491c504c5102852186d439b43 /activerecord/lib/active_record | |
parent | ad778bc422b338a7ef4de613a5919667ce2196ba (diff) | |
download | rails-9d599abe0febd96d7cd1f22e7d5f380187ae4476.tar.gz rails-9d599abe0febd96d7cd1f22e7d5f380187ae4476.tar.bz2 rails-9d599abe0febd96d7cd1f22e7d5f380187ae4476.zip |
do not hold on to a stale connection object. fixes #15998
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 12eaf36156..e94b6ae9eb 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -366,22 +366,27 @@ module ActiveRecord # This class is used to verify that all migrations have been run before # loading a web page if config.active_record.migration_error is set to :page_load class CheckPending - def initialize(app, connection = Base.connection) + def initialize(app) @app = app - @connection = connection @last_check = 0 end def call(env) - if @connection.supports_migrations? + if connection.supports_migrations? mtime = ActiveRecord::Migrator.last_migration.mtime.to_i if @last_check < mtime - ActiveRecord::Migration.check_pending!(@connection) + ActiveRecord::Migration.check_pending!(connection) @last_check = mtime end end @app.call(env) end + + private + + def connection + ActiveRecord::Base.connection + end end class << self |