Resource Reference
A resource is the unit Plutonium gives you full CRUD for — list, show, create, edit, delete — automatically. It's four cooperating layers, plus an optional fifth for business logic.
| Layer | File | What it controls |
|---|---|---|
| Model | app/models/post.rb | Data, validations, associations |
| Definition | app/definitions/post_definition.rb | UI — which fields, how they render, what actions exist |
| Policy | app/policies/post_policy.rb | Authorization — see Behavior › Policy |
| Controller | app/controllers/posts_controller.rb | Request handling — see Behavior › Controller |
| Interaction (optional) | app/interactions/publish_post_interaction.rb | Business logic for custom actions — see Behavior › Interaction |
How a resource is born
rails g pu:res:scaffold Post user:belongs_to title:string 'content:text?' --dest=main_app
rails db:migrate
rails g pu:res:conn Post --dest=admin_portalThat single scaffold gives you a working model + migration + controller + policy + definition. pu:res:conn adds it to a portal. See App › Generators for the full generator catalog.
Auto-detection is the default
Plutonium reads your model and renders every attribute automatically — type, label, form widget, display formatter, table column. You only declare overrides:
class PostDefinition < Plutonium::Resource::Definition
# No field/input/display/column needed unless you're overriding the default.
field :content, as: :markdown # override: render as markdown editor + viewer
input :title, hint: "Be descriptive"
endDon't declare for completeness
A field :title with no options that matches what Plutonium would auto-detect is dead code — it does nothing and clutters the file. Declare ONLY when you need a different type, an option, a condition:, a block, or a custom component.
Sub-pages
- Model —
Plutonium::Resource::Record,has_cents, SGID, custom routing, labeling - Definition — fields, inputs, displays, columns, page chrome, metadata panel, index views
- Query — search, filters, scopes, sorting
- Actions — custom actions, bulk actions, interaction integration
Related
- Guides › Adding Resources — task recipe
- App › Generators —
pu:res:scaffold/pu:res:connreference - Tenancy — multi-tenant scoping
