summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-12 04:16:49 -0400
committerPeter Kozak <spag@golwen.net>2013-03-12 04:16:49 -0400
commitf9ab4cb6a477159e40bd7f48d9ed32ca077a8e34 (patch)
treee63f95edab39cf09df1c115fb5bea51a9c7e8a5f /app
parent42c2396b485a3eaa0e8bdb995b3777c498b4f94d (diff)
remove non decimal characters from pin
Diffstat (limited to 'app')
-rw-r--r--app/models/conference.rb12
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