inertia-rails-controllers
Installation
SKILL.md
Inertia Rails Controllers
Server-side patterns for Rails controllers serving Inertia responses.
Before adding a prop, ask:
- Needed on every page? →
inertia_sharein a base controller (InertiaController), not a per-action prop - Expensive to compute? →
InertiaRails.defer— page loads fast, data streams in after - Only needed on partial reload? →
InertiaRails.optional— skipped on initial load - Reference data that rarely changes? →
InertiaRails.once— cached across navigations
NEVER:
- Use
redirect_tofor external URLs (Stripe, OAuth, SSO) — it returns 302 but the Inertia client tries to parse the response as JSON, causing a broken redirect. Useinertia_location(returns 409 +X-Inertia-Locationheader). - Use
errors.full_messagesfor validation errors — it produces flat strings without field keys, so errors can't be mapped to the corresponding input fields on the frontend. Useerrors.to_hash(true). - Use
inertia.defer,Inertia.defer, orinertia_rails.defer— the correct syntax isInertiaRails.defer { ... }. All prop helpers are module methods on theInertiaRailsconstant. - Assume instance variables are auto-passed as props — they are NOT (unless
alba-inertiagem is configured). Every action that passes props to the frontend MUST callrender inertia: { key: data }. - Use
success/erroras flash keys without updatingconfig.flash_keys— Rails defaults tonotice/alert. Custom keys must be added to both the initializer config and theFlashDataTypeScript type.
Render Syntax
Related skills