diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-03-12 11:23:57 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-03-12 11:23:57 +0100 |
commit | b16aeeccff8de5fd579d79a48740df7a3e34e7bc (patch) | |
tree | bb2ddcb29c6a465d73a3010437bdd076d11360c9 /app/models/conference.rb | |
parent | 3c5a0511d228fb3dc00ae860ade1b8ff032cc42f (diff) | |
parent | 40b2feb99d75074319f371087c521df198527266 (diff) |
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'app/models/conference.rb')
-rw-r--r-- | app/models/conference.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/conference.rb b/app/models/conference.rb index aee75d5..6c89d60 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -7,6 +7,12 @@ class Conference < ActiveRecord::Base has_many :conference_invitees, :dependent => :destroy has_many :phone_numbers, :as => :phone_numberable, :dependent => :destroy + before_validation { + if !self.pin.blank? + self.pin = self.pin.to_s.gsub(/[^0-9]/, '') + end + } + validates_presence_of :conferenceable_type, :conferenceable_id validates_presence_of :conferenceable validates_presence_of :name @@ -21,15 +27,12 @@ class Conference < ActiveRecord::Base validates_inclusion_of :open_for_anybody, :in => [true, false] - validates_numericality_of :pin, :only_integer => true, - :greater_than => 0, - :allow_nil => true, - :allow_blank => true validates_length_of :pin, :minimum => (GsParameter.get('MINIMUM_PIN_LENGTH').nil? ? 4 : GsParameter.get('MINIMUM_PIN_LENGTH')), :allow_nil => true, :allow_blank => true validate :start_and_end_dates_must_make_sense, :if => Proc.new { |conference| !conference.start.blank? && !conference.end.blank? } + before_save :send_pin_email_when_pin_has_changed @@ -50,7 +53,6 @@ class Conference < ActiveRecord::Base private def start_and_end_dates_must_make_sense - errors.add(:start, 'must be in the future') if self.start < Time.now - 10.minutes errors.add(:end, 'must be later than the start') if self.end < self.start end |