Generators
A scaffold writes the migration, model, controller, views, test and route for a resource, and the result runs.
$ ticket g scaffold Post title:String body:String? published:Bool:default=false
create src/schema.px 20261006_101500 create_table posts
create src/models/post.px
create src/controllers/posts_controller.px
create src/views/post_views.px
create src/controllers/posts_controller_test.px
append src/routes.px resources posts -> PostsController
The generated code is ordinary code that uses the public API
(Posts, Params.record,
Post.validate, Forms, Flash),
so you can edit it. The model gets presence for each
required String and uniqueness for each
unique column. Fields map to components:
String to TextField (TextArea
for body, description,
content), Int, Float and ids
to NumberField, Bool to
Checkbox.
| Command | What |
|---|---|
ticket g scaffold <Name> [f:T…] |
the files above |
ticket g controller <Names> <action…>
|
a controller, a stub view per action and a
get route each
|
ticket g model <Name> [f:T…] --validations
|
a model with a validations zone |
ticket destroy scaffold|model|controller
<Name>
|
removes the files and route lines. The migration stays, and
a file you edited needs --force
|
If a target file exists and differs, nothing is written and the
files are listed. --force overwrites,
--skip keeps them and writes the rest, and
--pretend prints the plan and writes nothing.