Skip to content

Commit 1de61b5

Browse files
committed
Defer the inclusion until after ActiveRecord has been fully loaded, improving booting performance and following Rails best practices
1 parent c6f6840 commit 1de61b5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/ar_after_transaction.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def delete_after_transaction_callbacks
8383
end
8484
end
8585

86-
ActiveRecord::Base.extend ARAfterTransaction::ClassMethods
87-
ActiveRecord::Base.include ARAfterTransaction::InstanceMethods
86+
ActiveSupport.on_load(:active_record) do
87+
ActiveRecord::Base.extend ARAfterTransaction::ClassMethods
88+
ActiveRecord::Base.include ARAfterTransaction::InstanceMethods
89+
end
8890
ActiveRecord::ConnectionAdapters::AbstractAdapter.include ARAfterTransactionConnection

0 commit comments

Comments
 (0)