caramel
Skip to content
Browse documentation
Cookbook / Data and forms

Create a resource.

Generate a book catalog, then make the model, actions, views, and request specs your own.

Draft recipeTarget: 0.7.1Not yet recipe-tested

Where the change goes

app/models/book.crThe stored shape
app/changesets/book.crRules for writes
app/actions/books/Request handling
app/views/books/Browser presentation
spec/requests/books_spec.crBehavior checks

Generate the feature

Run inside a configured application. Review the generated files and migration before applying it.

Terminal
frappe make resource Book title:string author:string
frappe migrate

For translated resources, run frappe make locale CODE before resource generation. Frappé then adds typed message calls and default catalog entries. Set up internationalization →

Choose the generated surface

original_url:string:url adds URL validation, a URL input, and valid request-spec samples. Use --only=create,show for a smaller resource; create and show are required, and edit needs new and update. Use :server for fields set by the action and :unique for a unique index and constraint checks.

Prove the behavior

Terminal
frappe check
frappe corretto spec/requests/books_spec.cr

The generated request spec exercises create, read, update, delete, and rejection of invalid requests. Extend it with your own validation rule and an example that fails that rule.