From 46ddd1590518873512a85f6203c0c6ef201024ee Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Wed, 15 Feb 2017 12:03:24 +0800 Subject: [PATCH] Use `ActiveSupport.on_load` to extend ActionController and ActionView. http://api.rubyonrails.org/classes/ActiveSupport/LazyLoadHooks.html https://github.com/rails/rails/blob/92703a9ea5d8b96f30e0b706b801c9185ef14f0e/actionpack/lib/action_controller/base.rb#L264 https://github.com/rails/rails/blob/7da8d76206271bdf200ea201f7e5a49afb9bc9e7/actionview/lib/action_view/base.rb#L215 --- lib/rucaptcha.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/rucaptcha.rb b/lib/rucaptcha.rb index ea4d1bf..de55b5b 100644 --- a/lib/rucaptcha.rb +++ b/lib/rucaptcha.rb @@ -35,5 +35,10 @@ module RuCaptcha end end -ActionController::Base.send(:include, RuCaptcha::ControllerHelpers) -ActionView::Base.send(:include, RuCaptcha::ViewHelpers) +ActiveSupport.on_load(:action_controller) do + ActionController::Base.send :include, RuCaptcha::ControllerHelpers +end + +ActiveSupport.on_load(:active_view) do + include RuCaptcha::ViewHelpers +end