Create a resource.
Generate a book catalog, then make the model, actions, views, and request specs your own.
| Contract | Value |
|---|---|
| Needs | A configured application |
| You will have | A Book model, changeset, migration, actions, views, routes and request spec |
| Status | Run end to end by scripts/check frappe-project, from frappe new to the passing spec; the options below are proved by the generator’s own specs |
| Proved by | frappe check · frappe corretto spec/requests/books_spec.cr |
Where the change goes
app/models/book.crThe stored shapeapp/changesets/book.crRules for writesdb/migrations/Creates the tableapp/actions/books.crShared form helpersapp/actions/books/Request handlingapp/views/books/Browser presentationconfig/routes.crSeven routes, insertedconfig/paths.crPath helpers, insertedspec/requests/books_spec.crBehavior checksDecide before you generate
Two choices change what the generator writes. Make them first.
- A multi-tenant application The resource belongs to the tenant unless you pass
--central. Set up multi-tenancy → - A translated application Run
frappe make locale CODEbefore resource generation. Frappé then adds typed message calls and default catalog entries. Set up internationalization →
Generate the feature
Run inside a configured application. Review the generated files and migration before applying it.
- Generate the resource
Terminal · inside the application frappe make resource Book title:string author:stringExpect: Prints
Generated PATHfor each of the 19 files it writes or edits: the seven actions andapp/actions/books.cr, the five views, the model, the changeset,db/migrations/…_create_books.cr,config/routes.cr,config/paths.crandspec/requests/books_spec.cr, thenRun frappe migrate to apply the new schema. Use frappe routes to see the generated URLs. - Apply the reviewed migration
Terminal · inside the application frappe migrateExpect: Prints
Applied 1 migrations., thenThe database matches the declared schema.
Choose the generated surface
| Pass | To get |
|---|---|
original_url:string:url | URL validation, a URL input, and valid request-spec samples |
--only=create,show | A smaller resource; create and show are required, and edit needs new and update |
--plural=people | An irregular plural for the table, the routes and the module |
:server | A field the action sets |
:unique | A unique index and constraint checks |
The field types are string, int32, int64, bool, float64 and time, each nullable with ?. Read the make resource syntax →
Extend the generated spec with your own validation rule and an example that fails that rule.
Prove it
Prove the behavior
frappe check
frappe corretto spec/requests/books_spec.crPassing: frappe check exits 0, and frappe corretto runs the generated request spec, which creates, reads, updates and deletes a book and refuses a forged token and an unknown field, then ends with Corretto: 1 of 1 workers passed.
scripts/check frappe-project creates an application, generates this resource and two more, migrates, and runs frappe check, frappe lint and frappe corretto on the result.