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 3 years have passed since last update.

ActiveRecord::RecordInvalid: バリデーションに失敗しました: Emailはすでに存在します

Posted at

とある状況でrails db:seedと入力すると__ActiveRecord::RecordInvalid: バリデーションに失敗しました: Emailはすでに存在します__と出てきてパソコン打ち壊しそうになったので備忘録。

状況

これが出てきたエラーです。長え

seed.rb_error.png

原因

スクリーンショット 2021-10-27 17.00.49.png

seed.rbのAdminに

email "a@a"
password "aaaaaa"

って記述してたんですけど、これまだ僕がseed.rbを利用する前に↑のemailとpasswordでサインアップに使用していたためこんなエラーが出てきたようです。
この部分のemailとpasswordに登録させる内容を変更させたらうまく行きました。

*ここではgemで日本語化のやつを導入してたから__ActiveRecord::RecordInvalid: バリデーションに失敗しました: Emailはすでに存在します__なんて日本語でエラーが出てきたのかもしれない。導入してなかったら英語で出てくると思われる。

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?