Hotwire Discussion

Render a turbo stream from outside of controller action

How can I do this I have a rescue callback in the controller for 404s and when it hits that it was rendering a 404 template this would replace everything breaking the permanent stuff in the nav I just want to target a div with an id = INNER-CONTENT and replace it with an errors partial

    rescue_from ActiveRecord::RecordNotFound, :with => :render_404
     def render_404
       render turbo_stream: turbo_stream.update("INNER-CONTENT", partial: "errors/error_404")

This results in just showing the generated turbo stream as text and doesnt execute

Seems like sometimes it does work Just got it after a weird edit form submission

Could you provide a sample app or more code to make it easier to understand why it isn’t working?