Sha256: 61283f3b180ed37eb784d39cf9bdd55c74b67032a24f87307e32a7973148e8e8
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 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 # 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ecm_courses-0.0.1 | app/models/ecm/courses/course.rb |
ecm_courses-0.0.7.pre | app/models/ecm/courses/course.rb |