Skip to content

Instantly share code, notes, and snippets.

@artificemm
Created May 24, 2015 05:38
Show Gist options
  • Save artificemm/deda549c857fb95ab222 to your computer and use it in GitHub Desktop.
Save artificemm/deda549c857fb95ab222 to your computer and use it in GitHub Desktop.
I hate UPCASE data on the DB, so I made this to prevent it
#I hate UPCASE data on the DB, so I made this to prevent it
before_save :titleize_fields
def titleize_fields
['name', 'paternal_lastname', 'maternal_lastname', 'spouse'].each do |m|
self.send("#{m}=", instance_eval(%Q{#{m}.titleize unless #{m}.nil?}))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment