Scaffold
sh
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.
Opt-in concerns
The generated model ships with commented-out hooks for Trek's most useful concerns, ready to be enabled when needed:
ruby
class Book < ApplicationRecord
# include Trek::Formattable
# format_attributes Trek::TypographyFormatter, :title
# include Trek::Translatable
# translate_attributes :title
# include RecordImageUploader::Attachment(:image)
strip_attributes
end