Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 为什么Rails 4.2.6唯一性:true,区分大小写:true失败?_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails 为什么Rails 4.2.6唯一性:true,区分大小写:true失败?

Ruby on rails 为什么Rails 4.2.6唯一性:true,区分大小写:true失败?,ruby-on-rails,ruby,Ruby On Rails,Ruby,我有一个简单的测试要执行。以下是以下代码: it 'should validate that email is lowercase' do account = build(:account, email: 'IRONMAN@gmail.com') lowercase_account = build(:account, email: 'warmachine@gmail.com') account.wont_be :valid? lowercase_account

我有一个简单的测试要执行。以下是以下代码:

  it 'should validate that email is lowercase' do
    account = build(:account, email: 'IRONMAN@gmail.com')
    lowercase_account = build(:account, email: 'warmachine@gmail.com')
    account.wont_be :valid?
    lowercase_account.must_be :valid?
  end
根据我的测试,
IRONMAN@gmail.com
应失败且
warmachine@gmail.com
应该通过。然而,当我运行测试时,两封电子邮件都通过了

这是我的
帐户
模型的验证代码

validates :email, presence: :true, length: { in: 3..100 }, uniqueness: true,
                  confirmation: true, email_format: true, allow_blank: false
validates :email_confirmation, email_format: true, presence: true, allow_blank: false, on: :create

这里可能有什么错误?我在上引用了此链接,以此作为起点。它有一些很好的信息,但我使用Postgresql而不是MySQL来执行帐户插入。据我所知,Postgresql不会进行不区分大小写的搜索,所以我应该很好。有人遇到过这个问题吗?

区分大小写并不意味着所有内容都必须小写才能有效,它意味着您可以有两封类似
hello@example.com
HELLO@example.com

如果区分大小写设置为false,则不能使用
hello@example.com
HELLO@example.com