Skip to content

Commit 84713fb

Browse files
committed
use on_load for rails 3 and to_prepare for rails 2
1 parent 7c6b6ff commit 84713fb

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/attr_encrypted/adapters/active_record.rb

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

136-
ActiveSupport.on_load(:active_record) do
137-
extend AttrEncrypted
138-
extend AttrEncrypted::Adapters::ActiveRecord
136+
if defined?(ActiveSupport.on_load)
137+
ActiveSupport.on_load(:active_record) do
138+
extend AttrEncrypted
139+
extend AttrEncrypted::Adapters::ActiveRecord
140+
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
139148
end
140149
end

0 commit comments

Comments
 (0)