joost / phony_rails

This Gem adds useful methods to your Rails app to validate, display and save phone numbers. It uses the super awesome Phony gem (https://github.com/floere/phony).
MIT License
556 stars 111 forks source link

default_country_code based on relation #174

Closed kimyu92 closed 6 years ago

kimyu92 commented 6 years ago

Is it possible to support relation-based default_country_code

phony_normalize :phone, default_country_code: -> { model.country_code }, add_plus: false
sergioisidoro commented 6 years ago

Yeah, I struggled with the same issue. I was expecting this to work:

phony_normalize :phone, default_country_code: Proc.new { |instance| instance.country } 
joost commented 6 years ago

Pull requests always welcome.