Quick example: A user enters a username into a form, and I need to make that text username before storing it in the app's database, thereby making it permanently lowercase.
Where would I put this code, and how would I access the data to be lowercased?
Thanks.
you should overwrite the attribute writer:
class User < ActiveRecord::Base def username=(val) write_attribute(:username, val.downcase) end end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With