I’m surprised that Rails does not seem to extend custom renderers to turbo streams.
Given a custom renderer :foo
, in controllers you can do:
render foo: ...
But it won’t let you do:
turbo_stream.update(..., foo: ...)
If you try, it will raise “You invoked render but did not give any of :body, :file, :html, :inline, :partial, :plain, :renderable, or :template option.”
Presumably, that’s because calls to turbo-stream actions already happen as part of another call to render
with the option :turbo_stream
.
I could write my own custom turbo-stream action (turbo_stream.foo(...)
), but that doesn’t really seem like the right place for that and it wouldn’t be as idiomatic.
Is there any way to get the syntax I want?