Rails validates_uniqueness_of across multiple columns with case insensitivity

前端 未结 1 951
南笙
南笙 2021-02-13 09:54

I have a model that has two fields, which I will call first_name and last_name, and I want to make sure that the combination of the two are case-insensitively unique. I\'ve gott

相关标签:
1条回答
  • 2021-02-13 10:55

    Did you try validates_uniqueness_of :first_name, :scope => :last_name, :case_sensitive => false?

    The documentation says it's true by default.

    (I think the link you gave is to some outdated documentation. IIRC, the default for this did change in the last couple of years.)

    0 讨论(0)
提交回复
热议问题