Skip to content

MenuNode

Hierarchical menu builder: each node links to a Page, an ExternalLink, or any custom linkable model.

Columns

ColumnTypeNotes
keystringunique within its parent, optional
title / labeljsonbtranslated texts
parent_idbiginttree hierarchy
positionintegerordering among siblings
linkable_type / linkable_idstring / bigintpolymorphic target
icon_keystringoptional icon
modifiersstringstyling flags

Behavior

  • has_closure_tree for the hierarchy, Orderable for positions
  • belongs_to :linkable, polymorphic: true, optional: true
  • Includes Translatable and strip_attributes

Notable methods

MethodReturns
to_stitle, label or key
to_paramkey or id
icon? / iconwhether an icon is set / the IconComponent for it
external_link?whether the target is an ExternalLink

Released under the MIT License.