From 1e2506e77d04d02b15f34cbdd83109ad579cc89e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 12 Mar 2013 04:17:06 -0400 Subject: remove non decimal characters from pin --- app/models/conference_invitee.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/models/conference_invitee.rb b/app/models/conference_invitee.rb index d6e3bac..6a1349e 100644 --- a/app/models/conference_invitee.rb +++ b/app/models/conference_invitee.rb @@ -1,21 +1,23 @@ class ConferenceInvitee < ActiveRecord::Base attr_accessible :pin, :speaker, :moderator, :phone_number, :phone_number_attributes - + belongs_to :conference belongs_to :phone_book_entry has_one :phone_number, :as => :phone_numberable, :dependent => :destroy accepts_nested_attributes_for :phone_number + before_validation { + if !self.pin.blank? + self.pin = self.pin.to_s.gsub(/[^0-9]/, '') + end + } + validates_presence_of :conference_id validates_presence_of :conference validates_presence_of :phone_number - 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 + validates_length_of :pin, :minimum => (GsParameter.get('MINIMUM_PIN_LENGTH').nil? ? 4 : GsParameter.get('MINIMUM_PIN_LENGTH')), + :allow_nil => true, + :allow_blank => true validates_inclusion_of :speaker, :in => [true, false] validates_inclusion_of :moderator, :in => [true, false] -- cgit v1.2.3