Sha256: be27ca645a782c3e75184856d377a7467a5f74fa857433856c9375c5f65c1e6f

Contents?: true

Size: 637 Bytes

Versions: 1

Compression:

Stored size: 637 Bytes

Contents

module Shoppe
  class 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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoppe-0.0.15 app/models/shoppe/product_category.rb