Skip to content

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.

LayerFileWhat it controls
Modelapp/models/post.rbData, validations, associations
Definitionapp/definitions/post_definition.rbUI — which fields, how they render, what actions exist
Policyapp/policies/post_policy.rbAuthorization — see Behavior › Policy
Controllerapp/controllers/posts_controller.rbRequest handling — see Behavior › Controller
Interaction (optional)app/interactions/publish_post_interaction.rbBusiness logic for custom actions — see Behavior › Interaction

How a resource is born

bash
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_portal

That 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:

ruby
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"
end

Don'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

  • ModelPlutonium::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

Released under the MIT License.