0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

'UNIQUE constraint failed'について

Posted at

#内容
DeviseのRegistrationsControllerのcreateアクションで

ActiveRecord::RecordNotUnique in Devise::RegistrationsController#create
SQLite3::ConstraintException: UNIQUE constraint failed: users.name

とでてしまう。

#解決
UNIQUE制約を受けているため、nameにあったunique: trueを消す。

add_index :users, :name, unique:true #←こいつを消す

今回はこれで解決できたが、どうしてもunique:trueを消したくない場合はどうするのだろう。
また調べていきたい。

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?