SQLite3 :: ConstraintException:UNIQUE约束失败:users.email:INSERT INTO" users"

时间:2017-09-19 08:43:38

标签: ruby-on-rails ruby ruby-on-rails-4 devise

我刚安装了设计宝石,我收到了以下错误:

Error:
AccountsControllerTest#test_should_update_account:
ActiveRecord::RecordNotUnique: SQLite3::ConstraintException: UNIQUE  constraint failed: users.email: INSERT INTO "users" ("created_at", "updated_at", "id") VALUES ('2017-09-19 08:32:47.975048', '2017-09-19 08:32:47.975048', 298486374)

这是我遵循的程序:

gem 'devise'
bundle install
rails generate devise:install
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
rails generate devise user
devise_for :users, path: 'users'
config.scoped_views = true
rails g devise:views users
rails generate devise:controllers users

知道可能出现什么问题吗?

1 个答案:

答案 0 :(得分:4)

我找到了解决方案!我不得不将test/fixtures/users.yml文件更改为:

one:
  email: test1@test.com

two:
  email: test2@test.com