# Unique field

**URL:** <https://www.ruby-forum.com/t/unique-field/158044>\
**Category:** Rails\
**Created:** [January 18, 2009, 1:55pm UTC](https://www.ruby-forum.com/t/unique-field/158044 "2009-01-18T13:55:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://www.ruby-forum.com/u/dave)\
**Post date:** [January 18, 2009, 1:55pm UTC](https://www.ruby-forum.com/t/unique-field/158044/1 "2009-01-18T13:55:30Z")

</div>

Anyone point me in the direction of a tutorial to explain how I can  
add a checker to a form field to see whether it is already used within  
the database, i.e. check whether the username entered is unique

---

<div class="post-metadata">

**Author:** ![dave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://www.ruby-forum.com/u/dave)\
**Post date:** [January 18, 2009, 2:17pm UTC](https://www.ruby-forum.com/t/unique-field/158044/2 "2009-01-18T14:17:24Z")

</div>

validates\_uniqueness\_of

[http://api.rubyonrails.com/classes/ActiveRecord/Validations/ClassMethods.html#M001896](http://api.rubyonrails.com/classes/ActiveRecord/Validations/ClassMethods.html#M001896)

On Sun, Jan 18, 2009 at 6:06 PM, Dave [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Anyone point me in the direction of a tutorial to explain how I can  
> add a checker to a form field to see whether it is already used within  
> the database, i.e. check whether the username entered is unique
> 
> >

–

Natalie Wood - “The only time a woman really succeeds in changing a man  
is  
when he is a baby.”
