Model, controller or view - where to normalize data?

I have a login screen and I wish to normalize the login name for the purposes of INSERT and SELECT. In the model I have:

  def username=(name)     # keycase is a local extension of class String.     write_attribute(:username, name.keycase)   end

The attribute username of an new user is indeed stored as a normalized string. However, when logging on and I input the username in capital letters then the select fails, because the param value of username is not normalized. The question is, where do I perform this manipulation for the login? In the controller? In the view? Or is there a way to accomplish this in the model?