Sha256: 680148f7bf04aa3985bd88dcdfe26a6f3d406458c141c4cdaf9c41b98133e4a6

Contents?: true

Size: 833 Bytes

Versions: 2

Compression:

Stored size: 833 Bytes

Contents

class Cms::Category < ActiveRecord::Base
  
  ComfyPress.establish_connection(self)
  
  self.table_name = 'cms_categories'
  
  attr_accessible :label,
                  :categorized_type
  
  # -- 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

2 entries across 2 versions & 1 rubygems

Version Path
comfypress-0.1.4 app/models/cms/category.rb
comfypress-0.1.3 app/models/cms/category.rb