Skip to content

Instantly share code, notes, and snippets.

@maxloncar
Created March 9, 2023 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxloncar/d72dcd0852059d41e93ac67cfd994b90 to your computer and use it in GitHub Desktop.
Save maxloncar/d72dcd0852059d41e93ac67cfd994b90 to your computer and use it in GitHub Desktop.
Seeds
require 'faker'
5.times do
author = Author.create(
name: Faker::Name.name,
date_of_birth: Faker::Date.between(from: '1900-01-01', to: '2000-01-01')
)
author.books << Book.create(
title: Faker::Book.title,
year_published: Faker::Date.between(from: '1900-01-01', to: '2022-01-01').year,
pages: rand(100..500)
)
end
p "created #{Author.count} authors and #{Book.count} books"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment