Guest User

Untitled

a guest
Feb 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. class Customer < ActiveRecord::Base
  2.  
  3. before_validation :extract_phone
  4.  
  5. def phone
  6. read_attribute("phone").number_to_phone( value, :area_code => true, :delimiter => '-' )
  7. end
  8.  
  9. protected
  10.  
  11. def extract_phone=(val)
  12. write_attribute("phone", val.gsub!(\d+))
  13. end
  14.  
  15. end
Add Comment
Please, Sign In to add comment