Sha256: 779e56270ff20d23ba59a5927c525d0a5cb5bef845afb61e71887d3fac88ce75
Contents?: true
Size: 781 Bytes
Versions: 10
Compression:
Stored size: 781 Bytes
Contents
module Tenon module TenonContent class Row < Tenon::ApplicationRecord self.table_name = 'tenon_tenon_content_rows' # Scopes, attachments, etc. include Tenon::Reorderable default_scope -> { order(:list_order) } # Validations # Relationships belongs_to :item has_many :pieces, -> { order 'position' }, class_name: 'TenonContent::Piece', dependent: :destroy # Nested accepts_nested_attributes_for :pieces def set_row_type(row_type) self.row_type = row_type build_pieces end def row_type_class "Tenon::TenonContent::RowTypes::#{row_type}".constantize end private def build_pieces row_type_class.add_pieces_to(self) end end end end
Version data entries
10 entries across 10 versions & 1 rubygems