diff --git a/lib/datagrid.rb b/lib/datagrid.rb index da8579c..b8fb9aa 100644 --- a/lib/datagrid.rb +++ b/lib/datagrid.rb @@ -1,5 +1,6 @@ require "action_view" require "datagrid/configuration" +require "datagrid/engine" module Datagrid @@ -14,14 +15,7 @@ module Datagrid autoload :Configuration autoload :Helper - ::ActiveSupport.on_load(:action_view) do - ActionView::Base.send(:include, Datagrid::Helper) - end - autoload :FormBuilder - ::ActiveSupport.on_load(:action_view) do - ActionView::Helpers::FormBuilder.send(:include, Datagrid::FormBuilder) - end autoload :Renderer diff --git a/lib/datagrid/engine.rb b/lib/datagrid/engine.rb index fc567a1..7e67b4d 100644 --- a/lib/datagrid/engine.rb +++ b/lib/datagrid/engine.rb @@ -1,12 +1,14 @@ require "rails/engine" +require 'datagrid/helper' +require 'datagrid/form_builder' module Datagrid # @!private class Engine < ::Rails::Engine initializer "datagrid.helpers" do - #TODO: check why it doesn't work ActiveSupport.on_load :action_view do - include Datagrid::Helper + ActionView::Base.send(:include, Datagrid::Helper) + ActionView::Helpers::FormBuilder.send(:include, Datagrid::FormBuilder) end end end diff --git a/lib/datagrid/helper.rb b/lib/datagrid/helper.rb index f2b0566..4d16ae9 100644 --- a/lib/datagrid/helper.rb +++ b/lib/datagrid/helper.rb @@ -1,4 +1,3 @@ -require "datagrid/engine" require "action_view" module Datagrid