STI, asciidoc & polymorphic associations

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

Document and Manual share one table via single-table inheritance; the derived type column shows which is which, and Manual inherits Document's crud_structure (the gem walks the superclass). The body renders with as: :asciidoc. Comment has a polymorphic belongs_to :commentable — the cell links back to whichever model (a Book or a Document) owns the comment.

app/models/document.rb
class Document < ApplicationRecord            # Manual < Document (STI)
  include CrudComponents::Model
  crud_structure do
    attribute :body, as: :asciidoc
    fieldset :index, %i[type title created_at]   # `type` = STI discriminator
    fieldset :show,  %i[type title body created_at]
  end
end
app/models/comment.rb
belongs_to :commentable, polymorphic: true
fieldset :index, %i[commentable body created_at]   # commentable → nil-safe link to Book or Document

Read more: Fields & rendering  ·  Views

Documents & Manuals (STI — see the type column)

Type Title Created at
— House style guide 19 Nov 2026 23:29
Manual Shipping manual 19 Nov 2026 23:29
Manual Returns manual 19 Nov 2026 23:29

A manual, body rendered as asciidoc

Type
Manual
Title
Shipping manual
Body

Shipping

Pack books flat.

Tip
Use rigid mailers for hardcovers.
Region SLA

EU

2 days

US

5 days

Created at
19 Nov 2026 23:29

Comments (polymorphic commentable)

Commentable Body Created at
The Hidden Forest 1 Great reference. 19 Nov 2026 23:29
The Endless Mirror 2 See the shipping manual. 19 Nov 2026 23:29
The Ancient Winter 3 Great reference. 19 Nov 2026 23:29
The Dispossessed City 4 Great reference. 19 Nov 2026 23:29
The Quiet Mirror 5 Linked from onboarding. 19 Nov 2026 23:29
House style guide A customer asked about this. 19 Nov 2026 23:29
Shipping manual Linked from onboarding. 19 Nov 2026 23:29
Returns manual Great reference. 19 Nov 2026 23:29