Skip to content

Commit 4e7f876

Browse files
Merge pull request rails#46119 from jonathanhefner/action_text-renderer-always-fall-back-to-action_controller
Always provide a fallback renderer for Action Text
2 parents fb4a6d4 + 763941e commit 4e7f876

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

actiontext/lib/action_text/engine.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ def to_trix_content_attachment_partial_path
5959
end
6060

6161
initializer "action_text.renderer" do
62-
ActiveSupport.on_load(:action_controller_base) do
63-
ActiveSupport.on_load(:action_text_content) do
64-
self.default_renderer = Class.new(ActionController::Base).renderer
65-
end
66-
end
67-
6862
%i[action_controller_base action_mailer].each do |base|
6963
ActiveSupport.on_load(base) do
7064
around_action do |controller, action|

actiontext/lib/action_text/rendering.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ module Rendering # :nodoc:
88
extend ActiveSupport::Concern
99

1010
included do
11-
cattr_accessor :default_renderer, instance_accessor: false
1211
thread_cattr_accessor :renderer, instance_accessor: false
1312
delegate :render, to: :class
1413
end
1514

1615
class_methods do
16+
def action_controller_renderer
17+
@action_controller_renderer ||= Class.new(ActionController::Base).renderer
18+
end
19+
1720
def with_renderer(renderer)
1821
previous_renderer = self.renderer
1922
self.renderer = renderer
@@ -23,7 +26,7 @@ def with_renderer(renderer)
2326
end
2427

2528
def render(*args, &block)
26-
(renderer || default_renderer).render_to_string(*args, &block)
29+
(renderer || action_controller_renderer).render_to_string(*args, &block)
2730
end
2831
end
2932
end

0 commit comments

Comments
 (0)