Use ActiveSupport.on_load - #213
Andrew Kane
committed Aug 26, 2016
commit e7efa6165335b8753d997d82b2c7d0d0d9af151d
Showing 1
changed file with
7 additions
and 2 deletions
ahoy.rb b/lib/ahoy.rb
+7
-2
| @@ | @@ -114,8 +114,13 @@ module Ahoy |
| end | |
| if defined?(Rails) | |
| - | ActionController::Base.send :include, Ahoy::Controller |
| - | ActiveRecord::Base.send(:extend, Ahoy::Model) if defined?(ActiveRecord) |
| + | ActiveSupport.on_load(:action_controller) do |
| + | ActionController::Base.send :include, Ahoy::Controller |
| + | end |
| + | |
| + | ActiveSupport.on_load(:active_record) do |
| + | ActiveRecord::Base.send(:extend, Ahoy::Model) |
| + | end |
| # ensure logger silence will not be added by activerecord-session_store | |
| # otherwise, we get SystemStackError: stack level too deep | |