Trek::Sectionable
Organizes a record's content into ordered, typed sections (hero, features, testimonials…).
What it adds
When the app has a Section model:
has_many :sections, -> { ordered }, as: :sectionable, dependent: :destroysections_instances— the unwrapped section objects, in order
Requirements
Trek doesn't generate the Section model: the app provides it, with a polymorphic belongs_to :sectionable, an ordered scope, and a section method returning the section's own object. Without a Section model, the concern adds nothing.
Usage
ruby
class Page < ApplicationRecord
include Trek::Sectionable
end
page.sections_instances.each do |section|
render section_component_for(section)
endSections are opt-in per page via the sectioned boolean column.