Sha256: 47d5ecb0a28066833fe292f267183b0429f578dc0c6cc6a8928497e3f924435c

Contents?: true

Size: 786 Bytes

Versions: 3

Compression:

Stored size: 786 Bytes

Contents

class Cms::Category < ActiveRecord::Base
  
  ComfortableMexicanSofa.establish_connection(self)
  
  self.table_name = 'cms_categories'
  
  # -- Relationships --------------------------------------------------------
  belongs_to :site
  has_many :categorizations,
    :dependent => :destroy
    
  # -- Validations ----------------------------------------------------------
  validates :site_id, 
    :presence   => true
  validates :label,
    :presence   => true,
    :uniqueness => { :scope => [:categorized_type, :site_id] }
  validates :categorized_type,
    :presence   => true
    
  # -- Scopes ---------------------------------------------------------------
  default_scope{ order(:label) }
  
  scope :of_type, lambda { |type|
    where(:categorized_type => type)
  }
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.9.2 app/models/cms/category.rb
comfortable_mexican_sofa-1.9.1 app/models/cms/category.rb
comfortable_mexican_sofa-1.9.0 app/models/cms/category.rb