Skip to content

Commit

Permalink
Revert "Avoid loading ActionView::Base during initialization (#1528)" (
Browse files Browse the repository at this point in the history
…#1626)

* Revert "Avoid loading ActionView::Base during initialization (#1528)"

This reverts commit 22dbe8f.

* Put back changelog

* Adding changelog for revert
  • Loading branch information
jonrohan committed Jan 11, 2023
1 parent 6aba644 commit 223c55d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 32 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ nav_order: 5

## main

* Revert "Avoid loading ActionView::Base during initialization (#1528)"

*Jon Rohan*

* Fix tests using `with_rendered_component_path` with custom layouts.

*Ian Hollander*
Expand Down
2 changes: 1 addition & 1 deletion lib/view_component/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class << self
#
# @return [ViewComponent::Config]
def config
@config ||= ActiveSupport::OrderedOptions.new
@config ||= ViewComponent::Config.defaults
end

# Replaces the entire config. You shouldn't need to use this directly
Expand Down
9 changes: 5 additions & 4 deletions lib/view_component/engine.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

require "rails"
require "view_component/config"
require "view_component/base"

module ViewComponent
class Engine < Rails::Engine # :nodoc:
config.view_component = ViewComponent::Config.defaults
config.view_component = ViewComponent::Base.config

rake_tasks do
load "view_component/rails/tasks/view_component.rake"
Expand All @@ -14,6 +14,9 @@ class Engine < Rails::Engine # :nodoc:
initializer "view_component.set_configs" do |app|
options = app.config.view_component

%i[generate preview_controller preview_route show_previews_source].each do |config_option|
options[config_option] ||= ViewComponent::Base.public_send(config_option)
end
options.instrumentation_enabled = false if options.instrumentation_enabled.nil?
options.render_monkey_patch_enabled = true if options.render_monkey_patch_enabled.nil?
options.show_previews = (Rails.env.development? || Rails.env.test?) if options.show_previews.nil?
Expand All @@ -36,8 +39,6 @@ class Engine < Rails::Engine # :nodoc:

initializer "view_component.enable_instrumentation" do |app|
ActiveSupport.on_load(:view_component) do
Base.config = app.config.view_component

if app.config.view_component.instrumentation_enabled.present?
# :nocov:
ViewComponent::Base.prepend(ViewComponent::Instrumentation)
Expand Down
18 changes: 0 additions & 18 deletions test/sandbox/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,6 @@
require "action_view/railtie"
require "sprockets/railtie"

# Track when different Rails frameworks get loaded.
# Ideally, none of them should be loaded until after initialization is complete.
# See config/initializers/zzz_complete_initialization.rb for the other half of this.
RAILS_FRAMEWORKS = [
:action_cable,
:action_controller,
:action_mailer,
:action_view,
:active_job,
:active_record
]
FRAMEWORK_LOAD_POINTS = {}
RAILS_FRAMEWORKS.each do |feature|
ActiveSupport.on_load(feature) do
FRAMEWORK_LOAD_POINTS[feature] = caller
end
end

require "view_component"

require "haml"
Expand Down

This file was deleted.

0 comments on commit 223c55d

Please sign in to comment.