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.

FactoryBotの[KeyError:Factory not registered: "user"]のエラー解決。

Posted at
1 / 2

KeyError:
Factory not registered: "user"

が出たので検索して調べた結果、factoriesディレクトリのusers.rbが関連してるような投稿を発見。

早速その中身を見に行こうとしたら...ファイルがなぜか存在しないことが判明!手動で作成し、中身を記述することに。

FactoryBot.define do
factory :user do
email {Faker::Internet.free_email}
password = '1a' + Faker::Internet.password
password { password }
password_confirmation { password }
nickname {'yyy'}
last_name {'かな'}
first_name {'かな'}
last_name_kana {'カナ'}
first_name_kana {'カナ'}
birth_info {'1999-12-21'}
end
end

無事解決しました。

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?