Skip to content

Commit 2cc9748

Browse files
author
Gabe Scholz
committed
Move React::Rails::ControllerHelper include to Railtie
1 parent b71b1c9 commit 2cc9748

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/react/rails/controller_helper.rb

-2
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,3 @@ def render_react_component(*args, &block)
1616
end
1717
end
1818
end
19-
20-
ActionController::Base.send(:include, React::Rails::ControllerHelper) if defined?(Rails)

lib/react/rails/railtie.rb

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ class Railtie < ::Rails::Railtie
2626
end
2727
end
2828

29+
# Include the react-rails controller helper lazily
30+
initializer "react_rails.setup_controller_helpers" do
31+
ActiveSupport.on_load(:action_controller) do
32+
include ::React::Rails::ControllerHelper
33+
end
34+
end
35+
2936
# run after all initializers to allow sprockets to pick up react.js and
3037
# jsxtransformer.js from end-user to override ours if needed
3138
initializer "react_rails.setup_vendor", :after => "sprockets.environment", group: :all do |app|

0 commit comments

Comments
 (0)