Skip to content

Commit

Permalink
Move AR railtie hook outside of initializer to avoid late inclusion o…
Browse files Browse the repository at this point in the history
…f shim
  • Loading branch information
adzap committed Feb 6, 2012
1 parent 43f4907 commit 48fd72a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/validates_timeliness/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
module ValidatesTimeliness
class Railtie < Rails::Railtie
initializer "validates_timeliness.initialize_active_record", :after => 'active_record.initialize_timezone' do
ActiveSupport.on_load(:active_record) do
ValidatesTimeliness.default_timezone = ActiveRecord::Base.default_timezone
ValidatesTimeliness.extend_orms = [ :active_record ]
end
ValidatesTimeliness.default_timezone = ActiveRecord::Base.default_timezone

This comment has been minimized.

Copy link
@stan

stan Feb 21, 2012

This breaks when using mongoid

This comment has been minimized.

Copy link
@adzap

adzap Feb 21, 2012

Author Owner

You mean moving the on_load hook out of this initializer hook?

What is the symptom?

This comment has been minimized.

Copy link
@stan

stan Feb 22, 2012

I mean leaving ActiveRecord::Base.default_timezone outside the on_load hook.

Created issue #66

end

initializer "validates_timeliness.initialize_restriction_errors" do
ValidatesTimeliness.ignore_restriction_errors = !Rails.env.test?
end
end
end

ActiveSupport.on_load(:active_record) do
ValidatesTimeliness.extend_orms = [ :active_record ]
end

0 comments on commit 48fd72a

Please sign in to comment.