Wednesday, 7 October 2015

Use of scope with validates_uniqueness_of rails

There is a :scope option that you can use to specify other attributes that are used to limit the uniqueness check:

Eg: I want to validate name should be unique with in the section

validates_uniqueness_of :name, scope: :section_id

2 comments: