Sha256: b5b757872bd3c18ba083c9065320ee200bd842307ea8461d4b8827a7290da362

Contents?: true

Size: 490 Bytes

Versions: 3

Compression:

Stored size: 490 Bytes

Contents

module Para
  class ComponentSection < ActiveRecord::Base
    has_many :components, -> { ordered }, class_name: 'Para::Component::Base',
             autosave: true, foreign_key: :component_section_id,
             dependent: :destroy

    scope :ordered, -> { order(position: :asc) }

    validates :identifier, presence: true

    def name
      read_attribute(:name) || I18n.t(
        "components.section.#{ identifier }",
        default: identifier.humanize
      )
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
para-0.5.1 app/models/para/component_section.rb
para-0.5.0 app/models/para/component_section.rb
para-0.4.0 app/models/para/component_section.rb