Skip to content

Conversation

@ne006
Copy link

@ne006 ne006 commented Mar 13, 2025

Rails by default includes all view helpers in a view's context when rendering it, but provides action_controller.include_all_helpers option (docs) to disable such behaviour:

config.action_controller.include_all_helpers = false 

When broadcasting to streams, Turbo::Streams::Broadcasts#render_format uses ApplicationController to call render.
Combined with disabled option above, for example a broadcast_render_to call fails when template uses some helpers not included by Rails automatically.

This patch introduces controller_klass option for Turbo::Streams::Broadcasts#render_format and methods built on top of it to pass a subclass of ActionController::Base which includes all the needed helpers and possibly other behaviour needed to successfully render the required template:

broadcast_render_to( 'items', template: 'items/update', format: ['turbo_stream'], locals: { item: self }, controller: V2::VerySpecificItemController ) 
@GuillouuH
Copy link

Commentaire de Matthieu sur Basecamp :

  • pourquoi le desactiver en local ? on peut pas tester du coup. Et sinon cf Campfire - Ruby on Rails le lien de simon juste au dessus
  • tu peux rajouter un return early if base_url_extension == "cn" return
  • comme ca il reste juste il locale == chine redirect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants