you should overwrite the attribute writer:
class User < ActiveRecord::Base
def username=(val)
write_attribute(:username, val.downcase)
end
end
Related Contents:
- Difference between rake db:migrate db:reset and db:schema:load
- How to redirect to a 404 in Rails?
- How do I parse JSON with Ruby on Rails? [duplicate]
- Run a single migration file
- difference between collection route and member route in ruby on rails?
- How do I create an average from a Ruby array?
- Rails :dependent => :destroy VS :dependent => :delete_all
- Ruby on Rails Callback, what is difference between :before_save and :before_create?
- Error installing libv8: ERROR: Failed to build gem native extension
- Removing a model in rails (reverse of “rails g model Title…”)
- Disable ActiveRecord for Rails 4
- ERROR: Error installing capybara-webkit:
- Rails: Validating min and max length of a string but allowing it to be blank
- Pushing app to heroku problem
- gem install permission problem
- Why are all Rails helpers available to all views, all the time? Is there a way to disable this?
- How to get request referer path?
- Rails /lib modules and
- How to access URL helper from rails module
- How to change hash keys from `Symbol`s to `String`s?
- can’t activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0
- Add image to layout in ruby on rails
- getaddrinfo: nodename nor servname provided, or not known
- Rails: ActiveRecord query based on association value
- Is there a way to avoid automatically updating Rails timestamp fields?
- How to flatten an array of arrays – but not all the way down
- attr_accessor default values
- Does dependency injection exist in Rails?
- convert string to specific datetime format?
- Why can’t I install the SQLite gem?
- Can’t Install ffi -v ‘1.9.18’ on macos Catalina
- How can I uninstall Ruby on ubuntu?
- Rails bundler doesn’t install gems inside a group
- STI, one controller
- How to use ActiveRecord in a ruby script outside Rails?
- Warning with fog and AWS: unable to load the ‘unf’ gem
- Check whether a string contains one of multiple substrings
- Rails – The system cannot find the path specified
- Rails – How do I check developer mode or production mode in code
- Rails : RuntimeError – can’t modify frozen Array when running rspec in rails
- ruby on rails how to deal with NaN
- Could not find rails (>= 0) amongst [] (Gem::LoadError)
- Ruby: How do I pass all parameters and blocks received by one method to another?
- How to call ApplicationController methods from ApplicationHelper
- How to change the default path of view files in a Rails 3 controller?
- Ruby on Rails: How can I edit database.yml for postgresql?
- How to get the latest record from each group in ActiveRecord?
- In which folder should I put “global” shared partial templates? [duplicate]
- Django or Ruby-On-Rails? [closed]
- How can I get Rspec to run all tests nested under a folder?