activerecord-safer_migrations icon indicating copy to clipboard operation
activerecord-safer_migrations copied to clipboard

Handle disabling timeouts in indirect ActiveRecord::Migration subclasses

Open jturkel opened this issue 7 years ago • 0 comments

Attempts to disable timeouts in non-direct subclasses of ActiveRecord::Migration fail in Rails 4.x with the following exception:

     NoMethodError:
       undefined method `say' for nil:NilClass
     # /Users/jturkel/.rvm/gems/ruby-2.3.4@activerecord-safer_migrations/gems/activerecord-4.2.9/lib/active_record/migration.rb:416:in `method_missing'
     # ./lib/active_record/safer_migrations/migration.rb:43:in `disable_lock_timeout!'

This was fixed in Rails 5.0 with https://github.com/rails/rails/commit/f37d92c41036d4eff168b8a8951a8b8a76baa347. This PR works around the issue in Rails 4.x by explicitly defining the ActiveRecord::Migration.say method which avoids the Rails bug in ActiveRecord::Migration.method_missing. The implementation of say was copied directly from Rails (with some rubocop fixes applied).

jturkel avatar Jul 18 '17 17:07 jturkel