Sha256: 971703928c1d01de93c832fb52cc908deeaf35f9e8fd2ba701f7c097db060a84
Contents?: true
Size: 712 Bytes
Versions: 8
Compression:
Stored size: 712 Bytes
Contents
module Shoppe class ProductCategory < ActiveRecord::Base self.table_name = 'shoppe_product_categories' # Categories have an image attachment attachment :image # All products within this category has_many :products, :dependent => :restrict_with_exception, :class_name => 'Shoppe::Product' # Validations validates :name, :presence => true validates :permalink, :presence => true, :uniqueness => true # All categories ordered by their name ascending scope :ordered, -> { order(:name) } # Set the permalink on callback before_validation { self.permalink = self.name.parameterize if self.permalink.blank? && self.name.is_a?(String) } end end
Version data entries
8 entries across 8 versions & 1 rubygems