Sha256: 363d8fefc1963357af803d1d1be14728c26e663a76b7283f0c529af32ab922c5

Contents?: true

Size: 612 Bytes

Versions: 6

Compression:

Stored size: 612 Bytes

Contents

class Plugins::Ecommerce::Attribute < ActiveRecord::Base
  self.table_name='plugins_ecommerce_attributes'
  belongs_to :site
  has_many :values, class_name: 'Plugins::Ecommerce::Attribute', foreign_key: :parent_id, dependent: :destroy
  belongs_to :product_attribute, class_name: 'Plugins::Ecommerce::Attribute', foreign_key: :parent_id
  scope :only_group, ->{ where(parent_id: nil) }
  scope :only_value, ->{ where.not(parent_id: nil) }
  default_scope ->{ order(position: :ASC) }
  def translated_values
    values.select(:id, :label, :key).map{|item| item.label = item.label.to_s.translate; item }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
camaleon_ecommerce-2.0.4 app/models/plugins/ecommerce/attribute.rb
camaleon_ecommerce-2.0.3 app/models/plugins/ecommerce/attribute.rb
camaleon_ecommerce-2.0.2 app/models/plugins/ecommerce/attribute.rb
camaleon_ecommerce-2.0.1 app/models/plugins/ecommerce/attribute.rb
camaleon_ecommerce-2.0.0 app/models/plugins/ecommerce/attribute.rb
camaleon_ecommerce-1.2.1 app/models/plugins/ecommerce/attribute.rb