Skip to content

PageVersion

Version history for pages: every snapshot of a versioned page's content and image. There is always exactly one current version per page; the others are archived.

Columns

ColumnTypeNotes
page_idbigintrequired
namestringversion label, auto-generated from the page title and date
contentjsonbProseMirror content snapshot
image_datajsonbShrine attachment snapshot
current_sincedatetimeset ⇔ this is the current version

Behavior

  • belongs_to :page — with Page#versions ordered most recent first
  • Validations guarantee one and only one current version per page
  • after_initialize sets a default name like "Page title (2026-06-10)"
  • Includes Sectionable, RecordImageUploader::Attachment(:image) and strip_attributes

Notable methods

MethodReturns
current?whether this version is the live one
other_versionsthe page's other versions
current_image / current_image_urlthis version's image

See Versionable for the page-side API (create_current_version_from_page!, current_content…).

Released under the MIT License.