Sha256: 392f6a59203d65b62788f27298e38222884aa7821b54752e601fd4f3b9359a35

Contents?: true

Size: 672 Bytes

Versions: 10

Compression:

Stored size: 672 Bytes

Contents

module Tienda
  class Product < ActiveRecord::Base

    # Product attributes for this product
    has_many :product_attributes, -> { order(:position) }, :class_name => 'Tienda::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

10 entries across 10 versions & 1 rubygems

Version Path
tienda-2.1.3 app/models/tienda/product/product_attributes.rb
tienda-2.1.2 app/models/tienda/product/product_attributes.rb
tienda-2.1.1 app/models/tienda/product/product_attributes.rb
tienda-2.1.0 app/models/tienda/product/product_attributes.rb
tienda-2.0.2 app/models/tienda/product/product_attributes.rb
tienda-2.0.1 app/models/tienda/product/product_attributes.rb
tienda-1.1.2 app/models/tienda/product/product_attributes.rb
tienda-1.1.1 app/models/tienda/product/product_attributes.rb
tienda-1.1.0 app/models/tienda/product/product_attributes.rb
tienda-1.0.0 app/models/tienda/product/product_attributes.rb