Sha256: d2c8d342b0f95d413a5877ac16a635ff2ecca8df641022b9cd4da3319f0d2f93

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

class ProductType < ActiveRecord::Base
  include Forgeos::Urlified

  translates :name, :url, :description
  define_translated_index :name, :url, :description

  has_many :products, :dependent => :destroy
  has_and_belongs_to_many_attachments

  has_and_belongs_to_many :product_attributes, :class_name => 'Attribute', :readonly => true
  has_and_belongs_to_many :dynamic_attributes, :class_name => 'Attribute', :readonly => true,
    :join_table => 'attributes_product_types', :association_foreign_key => 'attribute_id',
    :conditions => {:dynamic => true}

  has_and_belongs_to_many :categories, :readonly => true,
    :join_table => 'categories_elements', :foreign_key => 'element_id',
    :association_foreign_key => 'category_id', :class_name => 'ProductTypeCategory'

  validates :name, :presence => true

  has_many :brands, :through => :products, :uniq => true

  def self.modify_import_attributes(attributes)
    attributes[:url] = attributes[:name].parameterize if attributes[:url].blank? and attributes[:name].present?
    attributes
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
forgeos_commerce-1.9.1.rc1 app/models/product_type.rb
forgeos_commerce-1.9.0 app/models/product_type.rb