# Validates uniqueness scope

**URL:** <https://www.ruby-forum.com/t/validates-uniqueness-scope/185489>\
**Category:** Rails\
**Created:** [March 21, 2010, 11:30am UTC](https://www.ruby-forum.com/t/validates-uniqueness-scope/185489 "2010-03-21T11:30:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Angelo\_Ashmore](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/82dd89/32.png) [@Angelo\_Ashmore](https://www.ruby-forum.com/u/Angelo_Ashmore)\
**Post date:** [March 21, 2010, 11:30am UTC](https://www.ruby-forum.com/t/validates-uniqueness-scope/185489/1 "2010-03-21T11:30:51Z")

</div>

In a Rails 2.x validation to check if the name of some model is unique  
within a some category, I would use:

`validates_uniqueness_of :name, :scope => :category_id`

In Rails 3, this is replaced with:

`validates :name, :uniqueness => true`

However, I can’t seem to find a method of defining the uniqueness’  
scope. Am I missing something?

Thanks,  
Angelo
