diff --git a/lib/attr_encrypted/adapters/active_record.rb b/lib/attr_encrypted/adapters/active_record.rb index e8a0dfb5..81051c49 100644 --- a/lib/attr_encrypted/adapters/active_record.rb +++ b/lib/attr_encrypted/adapters/active_record.rb @@ -133,10 +133,17 @@ def method_missing_with_attr_encrypted(method, *args, &block) end end - Rails.configuration.to_prepare do - ActiveRecord::Base.class_eval do + if defined?(ActiveSupport.on_load) + ActiveSupport.on_load(:active_record) do extend AttrEncrypted extend AttrEncrypted::Adapters::ActiveRecord end + else + Rails.configuration.to_prepare do + ActiveRecord::Base.class_eval do + extend AttrEncrypted + extend AttrEncrypted::Adapters::ActiveRecord + end + end end end