Hotwire Discussion

Helpers when broadcasting partials

When we are subscribing to a stream with <%= turbo_stream_from 'admin_console' %>, and broadcasting updated partials when a model is changed
(ie: after_update_commit -> { broadcast_replace_to('admin_console', partial: '/admin/menu/uplink_status', target: "uplink_status_#{id}", locals: { record: self }) })
how can we influence the rendering context? If the partial references helper methods, they are not available in the view. I’ve resorted to doing something like this within the partial, which just feels… wrong:

<% self.extend(AdminHelper) %>

Can anyone suggest a better way to make helpers available within the partials rendered via model callback? I do realize this starts to blur the MVC lines, but there has to be some way to control the context without my hacky solution. I looked through the souce and see that ultimately it comes down to the call from the render_format method to ApplicationController.render(formats: [ format ], **rendering) but I couldn’t find any options that can be passed into the rendering hash that would influence the view context, but maybe I just missed something?

Thanks in advance!