Db 不播种:如何确定原因?

Db doesn't seed: how to determine the cause?

None seeds.rb 中的数据被加载到开发数据库中。没有错误信息。我怎样才能确定原因?

如果我 运行 rake:db:migrate:reset 它只是 运行 并且不会产生任何错误消息。如果我转到控制台 运行 User.first,它会显示 nil。我还下载了开发数据库,​​但里面没有记录(表创建正确,只是没有记录)。

有什么方法可以追查原因吗? seeds.rb的一部分:

User.create!(fullname:  "Example User",
                    username: "fakename0",
                    email: "example@railstutorial.org",
                    admin: true,
                    activated: true,
                    activated_at: Time.zone.now,
                    password:              "foobar",
                    password_confirmation: "foobar")

User.create!(fullname:  "Example User 2",
                    username: "fawwkename0",
                    email: "exaaample@railstutorial.org",
                    admin: false,
                    activated: true,
                    activated_at: Time.zone.now,
                    password:              "foobar",
                    password_confirmation: "foobar")

99.times do |n|
  fullname  = Faker::Name.name
  username  = "fakename#{n+1}"
  email = "example-#{n+1}@railstutorial.org"
  password = "password"
  User.create!(fullname:               fullname,
                      username:               username,
                      email:                  email,
                      password:               password,
                      password_confirmation:  password,
                      activated:              true,
                      activated_at:           Time.zone.now)
end

Message.create!(email: "example@example.com",
                name:  "Example User",
                content: "This is my message")

Organization.create!(org_name: "Fictious business",
                     bio: "The background of the organization here",
                     actioncode: 111)

99.times do |n|
  org_name  = Faker::Company.name
  bio = Faker::Lorem.paragraph(2)
  actioncode = Faker::Number.number(3)
  Organization.create!(org_name: org_name,
                     bio: bio,
                     actioncode: actioncode)
end

Member.create!(organization_id: rand(1..100),
                email: "me@example.com",
                username: "fake-name0",
                fullname: Faker::Name.name,
                activated: 1,
                activated_at: Time.zone.now,
                password: "foobar",
                password_confirmation: "foobar")

99.times do |n|
  organization_id = rand(1..100)
  email = "rails0-#{n+1}@example.com"
  username = "fake-name#{n+1}"
  fullname = Faker::Name.name
  activated = rand(0..1)
  activated_at = Faker::Date.backward(14) if activated==1
  password = "foobar"
  password_confirmation = "foobar"
  Member.create!(organization_id: organization_id,
                  email: email,
                  username: username,
                  fullname: fullname,
                  activated: activated,
                  activated_at: activated_at,
                  password: password,
                  password_confirmation: password_confirmation)
end

要加载 db/seeds.rb,您需要 运行 rake db:seed.