1

I have this sample_data.rake file:

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

It is placed on lib/tasks, and when i run rake db:populate I'm getting the next error.

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

I double checked this other posts: (How to build task 'db:populate' , Faker "Don't Know How to Build Task? , Rake aborted Uploading images using faker for ruby project.) and they didn't help.

Does anyone solved a issue like this?

Thanks a lot in advance.

Community
  • 1
  • 1
Marc Pursals
  • 762
  • 1
  • 8
  • 23

2 Answers2

5

enviroment should be :environment, as a correctly spelled Symbol.

task populate: :environment do
  # ...
deefour
  • 34,974
  • 7
  • 97
  • 90
1

You spelt enviroment wrongly! It should be environment.

Benjamin Tan Wei Hao
  • 9,621
  • 3
  • 30
  • 56