0

I am trying to save a client’s phone number to the DB and make it E.164 compliant so we can send them an SMS. We were using a gem to do this, but the powers that be decided they don’t want to do it that way anymore. I am trying to accomplish this using a before_validation and a model method. I have pasted them below, but can’t seem to figure out how to add a +1 that is required. Any help would be greatly appreciated.

listing_collection.rb

before_validation :format_phone

def format_phone
  self.client_phone = client_phone.gsub(/\D/, '')
end
tadman
  • 208,517
  • 23
  • 234
  • 262
Mike Wiesenhart
  • 316
  • 1
  • 4
  • 19

0 Answers0