Skip to content

Commit

Permalink
Compatibility fix (delegate #media_type in ActionController::Base) fo…
Browse files Browse the repository at this point in the history
…r Rails 5.2
  • Loading branch information
spohlenz committed May 11, 2024
1 parent c3e002f commit f54b166
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/trestle/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class Engine < ::Rails::Engine

initializer "turbo.renderer" do
ActiveSupport.on_load(:action_controller) do
# Compatibility fix for Rails 5.2
delegate :media_type, to: "@_response" unless instance_methods.include?(:media_type)

ActionController::Renderers.add :turbo_stream do |turbo_streams_html, options|
self.content_type = Mime[:turbo_stream] if media_type.nil?
turbo_streams_html
Expand Down

0 comments on commit f54b166

Please sign in to comment.