Yes, I think before_save is a good option for this. I donβt know if you had separate fields for the first / last and middle names, this would be easier because the middle name should not be capitalized.
Here is a simple implementation:
before_save :capitalize_names protected def capitalize_names ['first_name', 'last_name', 'middle_name'].each do |name| self.attributes[name] = self.attributes[name].capitalize end end
source share