Skip to content

Page

Hierarchical, translatable content pages with SEO metadata, versioning and stable URL paths. Generated into app/models/page.rb.

Columns

ColumnTypeNotes
keystringinternal identifier, optional
slugjsonbtranslated URL slug
titlejsonbtranslated title
descriptionjsonbtranslated description
contentjsonbProseMirror document
pageable_type / pageable_idstring / bigintpolymorphic link to a content model
parent_idbiginttree hierarchy
positionintegerordering among siblings
image_datajsonbShrine attachment
versionedbooleanenables versioning, default false
sectionedbooleanenables sections, default false
current_path_idbigintcurrent PagePath

Included concerns

Translatable (slug, title, description), Formattable, Contentable, Fragmentable, Orderable, Pathable, SearchEngineOptimizable, Sectionable, Sluggable, Versionable, Keyable, plus RecordImageUploader::Attachment(:image) and strip_attributes.

Associations

  • has_closure_tree — parent/children hierarchy (siblings, ancestors, descendants)
  • belongs_to :pageable, polymorphic: true, optional: true — the content model this page represents (see Pageable)
  • has_many :versionsPageVersion
  • has_many :paths and belongs_to :current_pathPagePath
  • has_many :menu_nodes, as: :linkableMenuNode

Validations & scopes

  • title presence; slug presence (unless root) and uniqueness within the parent
  • alpha_ordered — orders by translated title in the current locale

Notable methods

MethodReturns
full_paththe page's current URL path
find_at_full_path(path)class method — page lookup by path
parsed_content / formatted_content / content_textProseMirror content as hash / HTML / plain text
current_version / current_content / current_imageversioned content accessors
seo_values / meta_tagsSEO metadata with fallbacks
fragmentsthe fragments attached to this page key

Released under the MIT License.