# Model, controller or view - where to normalize data?

**URL:** <https://www.ruby-forum.com/t/model-controller-or-view-where-to-normalize-data/155962>\
**Category:** Rails\
**Created:** [December 18, 2008, 3:58pm UTC](https://www.ruby-forum.com/t/model-controller-or-view-where-to-normalize-data/155962 "2008-12-18T15:58:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [December 18, 2008, 3:58pm UTC](https://www.ruby-forum.com/t/model-controller-or-view-where-to-normalize-data/155962/1 "2008-12-18T15:58:56Z")

</div>

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?
