Skip to content

Commit 49ec99c

Browse files
committed
Ensure Rails.application is defined, use in preview source feature
1 parent e92d778 commit 49ec99c

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace :docs do
9595
require "rails"
9696
require "action_controller"
9797
require "view_component"
98-
ViewComponent::Base.config.view_component_path = "view_component"
98+
ViewComponent::GlobalConfig.view_component_path = "view_component"
9999
require "view_component/docs_builder_component"
100100

101101
error_keys = registry.keys.select { |key| key.to_s.include?("Error::MESSAGE") }.map(&:to_s)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<% if @render_args[:component] %>
2-
<% if ViewComponent::Base.config.render_monkey_patch_enabled || Rails.version.to_f >= 6.1 %>
2+
<% if ViewComponent::GlobalConfig.render_monkey_patch_enabled || Rails.version.to_f >= 6.1 %>
33
<%= render(@render_args[:component], @render_args[:args], &@render_args[:block]) %>
44
<% else %>
55
<%= render_component(@render_args[:component], &@render_args[:block]) %>
@@ -8,6 +8,6 @@
88
<%= render template: @render_args[:template], locals: @render_args[:locals] || {} %>
99
<% end %>
1010

11-
<% if ViewComponent::Base.config.show_previews_source %>
11+
<% if ViewComponent::GlobalConfig.show_previews_source %>
1212
<%= preview_source %>
1313
<% end %>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ViewComponent
2-
GlobalConfig = defined?(Rails) ? Rails.application.config.view_component : Base.config
2+
GlobalConfig = defined?(Rails) && Rails.application ? Rails.application.config.view_component : Base.config
33
end

0 commit comments

Comments
 (0)