Forum: Ruby on Rails Model, controller or view - where to normalize data?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2008-12-18 15:58
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?
This topic is locked and can not be replied to.