Project nº2 using Ruby on Rails (models only), and databases with Active Record
Simply run the seed file using :
$ rails db:seed
Here below is a description of the seed content :
require 'faker'
Stroll.destroy_all
City.destroy_all
Dog.destroy_all
Dogsitter.destroy_all
list_dog_names = ['Luna', 'Charlie', 'Bella', 'Daisy', 'Milo', 'Lucy', 'Cooper', 'Bailey', 'Teddy', 'Max', 'Zoe', 'Rocky', 'Nala', 'Roxy', 'Coco']
list_dog_breeds = ['Golden retriever', 'French bulldog', 'Labrador', 'German shepherd', 'Shiba inu', 'Chihuahua', 'Border collie']
list_cities = ['New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix', 'Philadelphia', 'San Antonio', 'San Diego', 'San Francisco']
list_cities.each do |city|
c = City.create!(city_name: city)
end
20.times do
d = Dog.create!(dog_name: list_dog_names.sample, dog_breed: list_dog_breeds.sample, city_id: City.all.sample.id)
end
20.times do
h = Dogsitter.create!(sitter_name: Faker::Name.first_name, city_id: City.all.sample.id)
end
50.times do
s = Stroll.new
s.date = Faker::Date.between(from: 2.years.ago, to: Date.today)
s.dog = Dog.all.sample
s.dogsitter = Dogsitter.all.sample
s.save
end
(Section to complete)