Module: InertiaJb::Controller
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/inertia_jb/controller.rb
Overview
Controller concern that renders .html.inertia templates as Inertia
responses.
A .html.inertia page template is reached through Rails' normal implicit
render. Its body (compiled by Handler) throws the props Hash back here,
which aborts the implicit render — layout and all — before we re-render the
page through inertia-rails' native renderer via render inertia:. Component
resolution, shared data, PropsResolver/partial reloads, config.layout,
SSR and the X-Inertia/Vary headers are therefore all handled by
inertia-rails, identically to a plain inertia-rails app.
Plain (non-Inertia) .html.erb actions never throw, so catch falls
through to super and they render exactly as in vanilla Rails.
InertiaRails::Controller is already mixed into ActionController::Base by
inertia-rails' engine, so we don't include it again.
Instance Method Summary collapse
Instance Method Details
#default_render ⇒ Object
23 24 25 26 |
# File 'lib/inertia_jb/controller.rb', line 23 def default_render(*) props = catch(:__inertia_jb) { return super } render(inertia: props) end |