Commit d1a14c7a authored by Mario Manno's avatar Mario Manno

use new validation syntax in several models

parent 308a1c53
......@@ -2,27 +2,16 @@ class Day < ActiveRecord::Base
include HumanizedDateRange
belongs_to :conference
# TODO a new day should search matching availabilities without a day:
# in case someone deletes a day, availabilities need to persist,
# so they can be reclaimed by a new day later
# if a.day_id.nil?
# on_create(day)
# conference.availabilities.each { |a|
# next unless a.day_id = nil
# a.day_id = @conference.days.map { |day| day.id
# if a.start_time.between?(day.start_date, day.end_date)
# or a.end_time.between?(day.start_date, day.end_date)
# or day.start_date.between?(a.start_time, a.end_time) }
has_many :availabilities
has_paper_trail meta: {associated_id: :conference_id, associated_type: "Conference"}
default_scope { order(start_date: :asc) }
validates_presence_of :start_date, message: "missing start date"
validates_presence_of :end_date, message: "missing end date"
validate :start_date_before_end_date, message: "failed validation"
validate :does_not_overlap, message: "overlaps, failed validation"
validates :start_date, presence: true
validates :end_date, presence: true
validate :start_date_before_end_date
validate :does_not_overlap
def start_date_before_end_date
self.errors.add(:end_date, "should be after start date") if self.start_date >= self.end_date
......
......@@ -4,7 +4,7 @@ class EventFeedback < ActiveRecord::Base
after_save :update_average
validates_presence_of :rating, message: "please select a value"
validates_presence_of :rating
protected
......
......@@ -5,7 +5,7 @@ class EventRating < ActiveRecord::Base
after_save :update_average
validates_presence_of :rating, message: "rating score was missing"
validates_presence_of :rating
validates :event, presence: true
validates :person, presence: true
......
......@@ -6,7 +6,7 @@ class Notification < ActiveRecord::Base
validates :reject_body, presence: true
validates :accept_body, presence: true
validates :accept_subject, presence: true
validate :uniq_locale, message: "this locale already exists for this call for papers"
validate :uniq_locale
# TODO
#validate :locale_is_valid
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment