Sha256: 5707c78d7229c9680e731c528d206ba1b93a956d335e9bbf5b4b49532efba263

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

module Shoppe
  class Product < ActiveRecord::Base

    # Product attributes for this product
    has_many :product_attributes, -> { order(:position) }, class_name: 'Shoppe::ProductAttribute'

    # Used for setting an array of product attributes which will be updated. Usually
    # received from a web browser.
    attr_accessor :product_attributes_array

    # After saving automatically try to update the product attributes based on the
    # the contents of the product_attributes_array array.
    after_save do
      if product_attributes_array.is_a?(Array)
        self.product_attributes.update_from_array(product_attributes_array)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoppe-1.1.2 app/models/shoppe/product/product_attributes.rb