Skip to content

Commit bd44d90

Browse files
authored
use on_load for rails 3 and to_prepare for rails 2
1 parent 4093a0b commit bd44d90

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/attr_encrypted/adapters/active_record.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,17 @@ def method_missing_with_attr_encrypted(method, *args, &block)
133133
end
134134
end
135135

136-
Rails.configuration.to_prepare do
137-
ActiveRecord::Base.class_eval do
136+
if defined?(ActiveSupport.on_load)
137+
ActiveSupport.on_load(:active_record) do
138138
extend AttrEncrypted
139139
extend AttrEncrypted::Adapters::ActiveRecord
140140
end
141+
else
142+
Rails.configuration.to_prepare do
143+
ActiveRecord::Base.class_eval do
144+
extend AttrEncrypted
145+
extend AttrEncrypted::Adapters::ActiveRecord
146+
end
147+
end
141148
end
142149
end

0 commit comments

Comments
 (0)