gpt4 book ai didi

ruby-on-rails - Faker : Don't know how to build task 'enviroment'

转载 作者:太空宇宙 更新时间:2023-11-03 17:24:18 24 4
gpt4 key购买 nike

<分区>

我有这个 sample_data.rake 文件:

namespace :db do
desc "Fill Patients with sample data"
task populate: enviroment do
Patient.create!(name: ["Example", "User"],
email: "example@gmail.com"
password: "foobar"
password_confirmation: "foobar"
age: "26"
doctor_id: "3"
dao: "true"
active: "true")
350.times do |n|
name=Faker::Name.name
email = "example-#{n+1}@gmail.com"
password = "password"
age = (25...45).sample
doctor_id = [2,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22].sample
dao = ["true", "false"].sample
active = "true"
Patient.create!(name: name,
email: email,
password: password,
password_confirmation: password,
age: age,
doctor_id: doctor_id
dao: dao,
active: active)
end
end
end

它位于 lib/tasks 上,当我运行 rake db:populate 时,我遇到了下一个错误。

rake aborted!
Don't know how to build task 'enviroment'
/home/marcpursals/.rvm/gems/ruby-1.9.3-p448@migtrace/bin/ruby_noexec_wrapper:14:in `eval'
/home/marcpursals/.rvm/gems/ruby-1.9.3-p448@migtrace/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:populate

我仔细检查了其他帖子:( How to build task 'db:populate'Faker "Don't Know How to Build Task?Rake aborted Uploading images using faker for ruby project 。)但它们没有帮助。

有人解决过这样的问题吗?

非常感谢。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com