From d7da36f0142bd8cdfdf604e607b233f23608f99f Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Wed, 13 Sep 2017 01:03:09 +0200 Subject: [PATCH] Load Rails helpers on ActionView loading. In some specific cases, ActionView might be loaded without ActionController. Fixes #38 --- CHANGELOG.md | 1 + lib/webpacker/react/railtie.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5ad6c1..df758b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - The whole `lodash` library was imported, resulting in a big bundle. Specific `lodash` functions`imports` are now used. +- Helpers are now loaded on `ActionView` loading (fixes #38) ## [0.3.1] - 2017-05-30 diff --git a/lib/webpacker/react/railtie.rb b/lib/webpacker/react/railtie.rb index 6b25d15..4775ae0 100644 --- a/lib/webpacker/react/railtie.rb +++ b/lib/webpacker/react/railtie.rb @@ -7,6 +7,10 @@ class Engine < ::Rails::Engine ActiveSupport.on_load(:action_controller) do ActionController::Base.helper ::Webpacker::React::Helpers end + + ActiveSupport.on_load :action_view do + include ::Webpacker::React::Helpers + end end initializer :webpacker_react_renderer, group: :all do |_app|