Given a person
ActiveRecord instance: person.phones #=> {home: '00123', office: '+1-45'}
Is there a more Ruby/Rails idiomatic way to do the following:
person_phones = person.phones
person_phones[:home] = person_phones[:home].sub('001', '+1')
person.update_column :phones, person_phones
The example data is irrelevant.
I only want to sub
one specific hash key value and the new hash to be saved in the database. I was wondering if there was a way to do this just calling person.phones
once, and not multiple times