Sha256: feb92db8b215f4dc571a1b0b631d6cf54580c751fc8566f71839d45dc6974e04

Contents?: true

Size: 912 Bytes

Versions: 1

Compression:

Stored size: 912 Bytes

Contents

module Kms
  class Product < ActiveRecord::Base
    include Liquor::Dropable
    extend FriendlyId
    include Kms::Permalinkable
    include Kms::CompileTemplates
    has_and_belongs_to_many :categories
    has_many :properties, dependent: :destroy

    has_many :product_option_types, dependent: :destroy
    has_many :option_types, through: :product_option_types

    has_many :variants,
      -> { where(type: Kms::Variant.name) },
      class_name: 'Kms::Variant', dependent: :destroy

    has_one :master, class_name: 'Kms::MasterVariant', dependent: :destroy

    friendly_id :name, use: :slugged

    # mount_uploader :image, ProductImageUploader
    # mount_uploader :preview_image, ProductImageUploader

    accepts_nested_attributes_for :master

    after_initialize :init_master

    protected

    def init_master
      return unless new_record?
      self.master ||= build_master
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kms_catalog-0.5.0 app/models/kms/product.rb