Form and Table
This demonstrates a very simple way of communicating directly with the backend.
For demo purposes, no real records are created here. After reloading the page, the records will disappear.
- View code: app/views/books
- Svelte Dropdown and modal templates are used directly from the npm package.
- Validations, enums and translations are done by the to_svelte ActiveRecord helper.
-
Server responses are flashed over Turbo Streams, by the
success_flashmethod on the ApplicationController (which could also live within the model). -
Distinguishing an XHR request from a Turbo Stream request or a Rails form submission is done by the
json_request?method within the ApplicationController, together with a general axios interceptor in application.js.
Books
| Title | Genre | Description |
|---|