Skip to content

Commit

Permalink
use on_load for rails 3 and to_prepare for rails 2
Browse files Browse the repository at this point in the history
  • Loading branch information
nightpool authored Jul 25, 2022
1 parent 4093a0b commit bd44d90
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/attr_encrypted/adapters/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bd44d90

Please sign in to comment.