Ruby on Rails – Can I modify data before it is saved?

you should overwrite the attribute writer:

class User < ActiveRecord::Base
  def username=(val)
    write_attribute(:username, val.downcase)
  end
end

Leave a Comment