Sha256: b09ead5bebe74644196290b948086e0fd67dcc85e0aca2546f4919edceba4618

Contents?: true

Size: 597 Bytes

Versions: 10

Compression:

Stored size: 597 Bytes

Contents

class Shoppe::ProductCategory < ActiveRecord::Base
  
  # Set the table name
  self.table_name = 'shoppe_product_categories'
  
  # Attachments
  attachment :image
  
  # Relationships
  has_many :products, :dependent => :restrict_with_exception, :class_name => 'Shoppe::Product'
  
  # Validations
  validates :name, :presence => true
  validates :permalink, :presence => true, :uniqueness => true

  # Scopes
  scope :ordered, -> { order(:name) }
  
  # Set the permalink
  before_validation { self.permalink = self.name.parameterize if self.permalink.blank? && self.name.is_a?(String) }
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shoppe-0.0.14 app/models/shoppe/product_category.rb
shoppe-0.0.13 app/models/shoppe/product_category.rb
shoppe-0.0.12 app/models/shoppe/product_category.rb
shoppe-0.0.11 app/models/shoppe/product_category.rb
shoppe-0.0.10 app/models/shoppe/product_category.rb
shoppe-0.0.9 app/models/shoppe/product_category.rb
shoppe-0.0.8 app/models/shoppe/product_category.rb
shoppe-0.0.7 app/models/shoppe/product_category.rb
shoppe-0.0.6 app/models/shoppe/product_category.rb
shoppe-0.0.5 app/models/shoppe/product_category.rb