Sha256: 8db0efccaac3c6d68dcafa001a734e447864a3cba6eaa6c7b5aa28e8d5eec3ee

Contents?: true

Size: 1.32 KB

Versions: 6

Compression:

Stored size: 1.32 KB

Contents

class Ecm::Courses::Course < ActiveRecord::Base
  # db settings
  self.table_name = 'ecm_courses_courses'
  
  # acts as list
  acts_as_list :scope => :ecm_courses_course_category
  
  # associations
  belongs_to :ecm_courses_course_category, 
             :class_name => Ecm::Courses::CourseCategory, 
             :counter_cache => :ecm_courses_courses_count
             
  has_many :ecm_courses_course_dates, 
           :class_name => Ecm::Courses::CourseDate, 
           :dependent => :destroy,
           :foreign_key => :ecm_courses_course_id,
           :order => 'start_at'
  
  # attibutes
  attr_accessible :description, 
                  :ecm_courses_course_category_id, 
                  :locale, 
                  :name
#                  :name, 
#                  :position, 
#                  :slug

  # friendly id
  extend FriendlyId
  friendly_id :name, :use => :slugged
    
  # validations 
  validates :ecm_courses_course_category, :presence => true
  validates :locale, :inclusion => { :in => I18n.available_locales.map(&:to_s) }, :unless => Proc.new { |c| c.locale.blank? }
  validates :name, :presence => true
  
  # public methods

  def heading_name
    locale_prefix = (locale.blank?) ? "" : "[#{locale}] "
    "#{locale_prefix}#{name}"
  end
  
  def to_s
    "#{ecm_courses_course_category.name} - #{name}"
  end  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ecm_courses-0.0.6.pre app/models/ecm/courses/course.rb
ecm_courses-0.0.5.pre app/models/ecm/courses/course.rb
ecm_courses-0.0.4.pre app/models/ecm/courses/course.rb
ecm_courses-0.0.3.pre app/models/ecm/courses/course.rb
ecm_courses-0.0.2.pre app/models/ecm/courses/course.rb
ecm_courses-0.0.1.pre app/models/ecm/courses/course.rb