Rails 4.1 Ruby 2.0 Windows 8.1
I have a three different models in my application where I need to "sanitize" the phone numbers and email prior to saving. Can I do something like this in each of the models:
before_save :sanitize_phones_and_email
and in helpers/application_helper.rb:
def sanitize_phones_and_email
(self.email = email.downcase) if attribute_present?("email")
(self.work_phone = phony_normalize work_phone, :default_country_code => 'US') if attribute_present?("work_phone")
(self.mobile_phone = phony_normalize mobile_phone, :default_country_code => 'US') if attribute_present?("mobile_phone")
(self.fax_phone = phony_normalize fax_phone, :default_country_code => 'US') if attribute_present?("fax_phone")
(self.other_phone = phony_normalize other_phone, :default_country_code => 'US') if attribute_present?("other_phone")
end
Would "self" be processed properly by Rails? (since I can't pass it as an argument to a method)