-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRakefile
29 lines (23 loc) · 1004 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require_relative './config/dotenv'
require_relative './models'
require 'faker'
task 'db:seed' do
# Create a new user
user = User.create({ :name => Faker::Name.name,
:bio => Faker::Lorem.paragraph(2),
:email => Faker::Internet.email,
:phone => Faker::PhoneNumber.phone_number,
:website => Faker::Internet.url })
# Create 5 jobs
jobs = Array.new(5) { Job.create({ :job_title => Faker::Name.title,
:job_description => Faker::Company.bs,
:company_name => Faker::Company.name })
}
# Create a random number of skills
skills = Array.new(rand(10)) { Skill.create({ :name => Faker::Hacker.ingverb }) }
# Associate the jobs and skills with the user
jobs.each { |job| user.jobs << job }
skills.each { |skill| user.skills << skill }
# Save the user and all associations
user.save
end