lib/action_view/component/railtie.rb in actionview-component-1.6.0 vs lib/action_view/component/railtie.rb in actionview-component-1.6.1
- old
+ new
@@ -1,7 +1,9 @@
# frozen_string_literal: true
+require "rails"
+
module ActionView
module Component
class Railtie < Rails::Railtie # :nodoc:
config.action_view_component = ActiveSupport::OrderedOptions.new
@@ -21,19 +23,26 @@
initializer "action_view_component.set_autoload_paths" do |app|
require "railties/lib/rails/components_controller"
require "railties/lib/rails/component_examples_controller"
+ app.config.eager_load_namespaces << ActionView::Component::Base
options = app.config.action_view_component
if options.show_previews && options.preview_path
ActiveSupport::Dependencies.autoload_paths << options.preview_path
end
end
initializer "action_view_component.compile_config_methods" do
ActiveSupport.on_load(:action_view_component) do
config.compile_methods! if config.respond_to?(:compile_methods!)
+ end
+ end
+
+ initializer "action_view_component.monkey_patch_render" do
+ ActiveSupport.on_load(:action_view) do
+ ActionView::Base.prepend ActionView::Component::RenderMonkeyPatch
end
end
config.after_initialize do |app|
options = app.config.action_view_component