Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix double registration of :turbo_stream Renderer
When an application loads both `ActionController::Base` and `ActionController::API`, the `:action_controller` load hook gets called twice (once for each of them). Since the `:turbo_stream` Renderer is registered in this load hook, it ends up getting registered twice and prints a warning for method redefinition. To demonstrate the warning in the `turbo-rails` tests, an `Api::ApplicationController` was added to the dummy app so that both base controller classes get loaded: ``` $ CI=true bundle exec rake test /home/hartley/.cache/asdf/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/actionpack-7.1.3/lib/action_controller/metal/renderers.rb:75: warning: method redefined; discarding old _render_with_renderer_turbo_stream /home/hartley/src/github.com/skipkayhil/turbo-rails/lib/turbo/engine.rb:67: warning: previous definition of _render_with_renderer_turbo_stream was here ``` This commit fixes the issue by not using the `:action_controller` load hook to register the `:turbo_stream` Renderer. Adding a Renderer should not require a lazy load hook because `ActionController::Renderers` does not load any other classes.
- Loading branch information