Sha256: da3c96c22bf3c4c54dc58a81c5795a1b431ac4a28c038d315a1e5a270cb9c288
Contents?: true
Size: 526 Bytes
Versions: 1
Compression:
Stored size: 526 Bytes
Contents
module Spina class StructureItem < ApplicationRecord before_validation :ensure_position belongs_to :structure has_many :structure_parts, dependent: :destroy scope :sorted_by_structure, -> { order('position') } validates_presence_of :position accepts_nested_attributes_for :structure_parts, allow_destroy: true def content(structure_part) structure_parts.find_by(name: structure_part).try(:content) end def ensure_position self.position ||= Time.now.to_i end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spina-0.10.0 | app/models/spina/structure_item.rb |