Renderers & manual actions

How this page is built the gem renders it — this is all you write

Some renderers are soft dependencies: as: :markdown uses a markdown gem (commonmarker/redcarpet/kramdown), as: :asciidoc uses asciidoctor, and the :json cell pretty-prints and (with rouge) syntax-highlights. The gem feature-detects them — it never requires them — and raises at structure build with a clear message if you declare one whose gem is missing. Below, blurb renders as Markdown and metadata as JSON. The second card shows manual action placement: render with actions: false and drop crud_actions wherever you like.

app/models/book.rb
attribute :blurb, as: :markdown      # commonmarker / redcarpet / kramdown
attribute :metadata, as: :json       # pretty-printed + rouge-highlighted
fieldset :renderers, %i[title blurb metadata]
app/views/renderers/index.html.erb
<%= crud_record @book, fieldset: :renderers %>

<%# place the buttons yourself instead of the built-in actions column %>
<%= crud_record @book, fieldset: :renderers, actions: false %>
<%= crud_actions @book %>     <%# row actions for a record %>
<%= crud_actions Book %>      <%# collection actions for the model class %>

Read more: Fields & rendering  ·  Views

Markdown & JSON cells

Title
The Hidden Forest 1
Blurb

The Hidden Forest 1ancient tales of the forest.

  • A story in 5 parts
  • Set in the Archive
Metadata
{
  "isbn": "978-480404538",
  "binding": "hardcover"
}

crud_actions — place the buttons yourself

The record renders with actions: false; the buttons below are placed by hand with crud_actions (row actions for the record, then collection actions for the class).

Title
The Hidden Forest 1
Price
28.24 €