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 committed Jul 27, 2022
1 parent 7c6b6ff commit 84713fb
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/attr_encrypted/adapters/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,17 @@ def method_missing_with_attr_encrypted(method, *args, &block)
end
end

ActiveSupport.on_load(:active_record) do
extend AttrEncrypted
extend AttrEncrypted::Adapters::ActiveRecord
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 84713fb

Please sign in to comment.