Trek::Sectionable
Organizes a record's content into ordered, typed sections (hero, features, testimonials…).
What it adds
has_many :sections, -> { ordered }, as: :sectionable, dependent: :destroysections_instances— the unwrapped section objects, in order
Usage
ruby
class Page < ApplicationRecord
include Trek::Sectionable
SECTIONS = [HeroSection, FeaturesSection].freeze
end
page.sections_instances.each do |section|
render section_component_for(section)
endSections are opt-in per page via the sectioned boolean column. The including class defines the allowed section types through the SECTIONS constant.