現在、usersテーブルに100件のダミーデータを追加使用したいと思い
下記コードを実行してみました
場所:db/seeds.rb
100.times do |n| email = Faker::Internet.email password = "password" User.create!(email: email, password: password, password_confirmation: password, ) end
こちらにを実行すると下記がエラーとして帰ってきました
エラーの内容が↓です
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint
なのでこちらを元に調べるとにた様な説明もありましたが、???です
全てパスワードが同じなどが問題なのでしょうか・・・?
すでに一部データがあるのでダブりの為×となっているのでしょうか?
有識者の方々、なぜダミーデータを作ろうとするとエラーがでるか
ヒントでいいので頂く事は可能でしょうか・・・?(><)
↓がエラーの内容です
何卒、何卒、何卒、ご意見をいただければ幸いです。
vagrant@vagrant-ubuntu-trusty:~/workspace/achieve$ rake db:seed rake aborted! ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_users_on_uid_and_provider" DETAIL: Key (uid, provider)=(, ) already exists. : INSERT INTO "users" ("email", "encrypted_password", "created_at", "updated_at", "confirmation_token", "confirmation_sent_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" /home/vagrant/workspace/achieve/db/seeds.rb:4:in `block in <top (required)>' /home/vagrant/workspace/achieve/db/seeds.rb:1:in `times' /home/vagrant/workspace/achieve/db/seeds.rb:1:in `<top (required)>' PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_users_on_uid_and_provider" DETAIL: Key (uid, provider)=(, ) already exists. /home/vagrant/workspace/achieve/db/seeds.rb:4:in `block in <top (required)>' /home/vagrant/workspace/achieve/db/seeds.rb:1:in `times' /home/vagrant/workspace/achieve/db/seeds.rb:1:in `<top (required)>' Tasks: TOP => db:seed (See full trace by running task with --trace) vagrant@vagrant-ubuntu-trusty:~/workspace/achieve$ vagrant@vagrant-ubuntu-trusty:~/workspace/achieve$ rake db:seed rake aborted! ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_users_on_uid_and_provider" DETAIL: Key (uid, provider)=(, ) already exists. : INSERT INTO "users" ("email", "encrypted_password", "created_at", "updated_at", "confirmation_token", "confirmation_sent_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" /home/vagrant/workspace/achieve/db/seeds.rb:4:in `block in <top (required)>' /home/vagrant/workspace/achieve/db/seeds.rb:1:in `times' /home/vagrant/workspace/achieve/db/seeds.rb:1:in `<top (required)>' PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_users_on_uid_and_provider" DETAIL: Key (uid, provider)=(, ) already exists. /home/vagrant/workspace/achieve/db/seeds.rb:4:in `block in <top (required)>' /home/vagrant/workspace/achieve/db/seeds.rb:1:in `times' /home/vagrant/workspace/achieve/db/seeds.rb:1:in `<top (required)>' Tasks: TOP => db:seed (See full trace by running task with --trace) vagrant@vagrant-ubuntu-trusty:~/workspace/achieve$
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/05/08 00:11
2017/05/08 13:09