Skip to content

Conversation

skryukov
Copy link
Contributor

There are two ways to address the ActionView::MissingTemplate issue: using a respond_to block or forcing the :html format. I went with the latter since it prevents all cryptic messages and makes the controller always render an Inertia response.

Fixes #248

@richardboehme
Copy link

Can confirm this works in our app. The server now always responds with HTML, no matter the requested content type.

@bknoles
Copy link
Collaborator

bknoles commented Aug 28, 2025

I played with this a bit today. I'm in favor of wrapping the renderer in a repond_to block.

IMO the issue is that we're raising a confusing exception.

With a respond_to block constraining us to html formats, Rails raises an UnknownFormat error, which I think is a helpful exception. Since there are still ways the app can decide to support /some_inertia_path.some_other_format if it wants to, coercing it in the renderer is overly prescriptive for me. What do you think?

@bknoles
Copy link
Collaborator

bknoles commented Aug 28, 2025

We could also constrain the format coercion to the static controller, perhaps... this seems to work if I forward the formats argument on to the render method call in the renderer:

module InertiaRails
  class StaticController < InertiaRails.configuration.parent_controller.constantize
    def static
      render inertia: params[:component], formats: [:html]
    end
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ActionView::MissingTemplate with InertiaRails::StaticController
3 participants