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
No records

Comments (polymorphic commentable)

Commentable Body Created at
No records