Sha256: c49dd13a6cf34bd5cdbb1f970fc9e392545299f51e47449561521960e1e5f98c

Contents?: true

Size: 792 Bytes

Versions: 4

Compression:

Stored size: 792 Bytes

Contents

class Chouette::TimeTablePeriod < Chouette::ActiveRecord
  self.primary_key = "id"
  belongs_to :time_table
  acts_as_list :scope => 'time_table_id = #{time_table_id}',:top_of_list => 0

  attr_accessible :period_start, :period_end, :position,:time_table_id,:time_table
  
  validates_presence_of :period_start
  validates_presence_of :period_end
  
  validate :start_must_be_before_end

  def self.model_name
    ActiveModel::Name.new Chouette::TimeTablePeriod, Chouette, "TimeTablePeriod"
  end
  
  def start_must_be_before_end
    # security against nil values
    if period_end.nil? || period_start.nil?
      return
    end
    if period_end <= period_start
      errors.add(:period_end,I18n.t("activerecord.errors.models.time_table_period.start_must_be_before_end"))
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ninoxe-0.1.6 app/models/chouette/time_table_period.rb
ninoxe-0.1.5 app/models/chouette/time_table_period.rb
ninoxe-0.1.4 app/models/chouette/time_table_period.rb
ninoxe-0.1.3 app/models/chouette/time_table_period.rb