Sha256: 8b65fce93153cf20d763c866e952dcb98391a376893290a88f559bad4bbb4d25

Contents?: true

Size: 767 Bytes

Versions: 28

Compression:

Stored size: 767 Bytes

Contents

class Caboose::MediaCategory < ActiveRecord::Base

  self.table_name = "media_categories"  
  belongs_to :parent, :class_name => 'Caboose::MediaCategory'
  has_many :children, :class_name => 'Caboose::MediaCategory', :foreign_key => 'parent_id', :order => 'name'
  has_many :media_images, :class_name => 'Caboose::MediaImage', :order => 'name'
  has_many :media_files, :class_name => 'Caboose::MediaFile', :order => 'name'
  attr_accessible :id, :site_id, :parent_id, :name
  
  def self.top_image_category(site_id)
    return self.where("parent_id is null and site_id = ? and name = ?", site_id, 'Images').first
  end
  
  def self.top_file_category(site_id)
    return self.where("parent_id is null and site_id = ? and name = ?", site_id, 'Files').first
  end

end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
caboose-cms-0.4.71 app/models/caboose/media_category.rb
caboose-cms-0.4.70 app/models/caboose/media_category.rb
caboose-cms-0.4.69 app/models/caboose/media_category.rb
caboose-cms-0.4.68 app/models/caboose/media_category.rb
caboose-cms-0.4.67 app/models/caboose/media_category.rb
caboose-cms-0.4.66 app/models/caboose/media_category.rb
caboose-cms-0.4.65 app/models/caboose/media_category.rb
caboose-cms-0.4.64 app/models/caboose/media_category.rb
caboose-cms-0.4.63 app/models/caboose/media_category.rb
caboose-cms-0.4.62 app/models/caboose/media_category.rb
caboose-cms-0.4.61 app/models/caboose/media_category.rb
caboose-cms-0.4.60 app/models/caboose/media_category.rb
caboose-cms-0.4.59 app/models/caboose/media_category.rb
caboose-cms-0.4.58 app/models/caboose/media_category.rb
caboose-cms-0.4.57 app/models/caboose/media_category.rb
caboose-cms-0.4.56 app/models/caboose/media_category.rb
caboose-cms-0.4.55 app/models/caboose/media_category.rb
caboose-cms-0.4.54 app/models/caboose/media_category.rb
caboose-cms-0.4.53 app/models/caboose/media_category.rb
caboose-cms-0.4.52 app/models/caboose/media_category.rb