Scaffold
rails g trek:scaffold Book title intro:textAkin to Rails', Trek's scaffold generates, with a single command:
- the
Bookmodel and migration (calling the Railsmodelgenerator behind the scenes) - the
Admin::BooksController, inheriting fromTrek::ResourceController - the Slim views:
index,show,new,editand the_formpartial - the
Admin::BookPolicy, inheriting fromTrek::ResourcePolicy - the
resources :booksroute in theadminnamespace - the locale files for the model and its admin panel, in every configured locale (auto-translated via DeepL when
DEEPL_AUTH_KEYis set) - the entry in the admin dashboard menu
Field types
Standard Rails attribute types are supported (string, text, integer, float, decimal, boolean, date, datetime, references…) and mapped to the matching form helpers: text renders the content editor, boolean a switch box, references a collection select, and so on.
Namespaced models
rails g trek:scaffold Shop::Product name price:decimalThe controller and policy are nested accordingly (Admin::Shop::ProductsController, Admin::Shop::ProductPolicy), the routes go under namespace :shop, and everything else follows the namespace.
The generated code references the model as ::Shop::Product, top-level qualified, and the dashboard menu entry is ::Shop::Product too. This is deliberate: once Admin::Shop exists, a bare Shop written anywhere under module Admin resolves to that namespace instead of the Shop model. Existing admin code that references such a model — an Admin::ShopsController#model returning Shop, or a Shop entry in Admin::Dashboard::MODELS_IN_MENU — must be updated to ::Shop once a scaffold introduces a namespace with the same name (the menu would otherwise silently list the module).
Also note that rails g model Shop::Product (which the scaffold runs) writes app/models/shop.rb as a module Shop namespace file; if a Shop model already lives there, the generator warns and Rails asks before overwriting it — move the model or answer n.
Opt-in concerns
The generated model ships with commented-out hooks for Trek's most useful concerns, ready to be enabled when needed:
class Book < ApplicationRecord
# include Trek::Formattable
# format_attributes Trek::TypographyFormatter, :title
# include Trek::Translatable
# translate_attributes :title
# include RecordImageUploader::Attachment(:image)
strip_attributes
end