Validates_uniqueness_of problem

hi

Could I check to strings for uniqueness together and not individually?
That means for me in an example:

name: sex: result:


miller m unique
miller f unique
jackson m unique
miller m isn’t unique

So I want to check the name and sex be together unique. The name isn’t
individually. Because when I use the following codelines, the third
entry in the example isn’t unique, but I would!

validates_uniqueness_of :name
validates_uniqueness_of :sex

thx for your help!

I think you want

validates_uniqueness_of :name, :scope => :sex

  • Danny

Daniel B. wrote:

I think you want

validates_uniqueness_of :name, :scope => :sex

  • Danny

It’s run. Thank you!