Using Faker Gem To Seed Your Application

Film.create(:title => "The Shawshank Redemption")
Film.create(:title => "The GodFather")
Film.create(:title => "Forrest Gump")
100.times do
Film.create(:title => Faker::Movie.uniq.title)
end
100.times do
User.create(
full_name: Faker::Name.name,
date_of_birth: Faker::Date.birthday(min_age: 21, max_age: 65),
email: Faker::Internet.email,
occupation: Faker::Job.title,
favorite_basketball_team: Faker::Sports::Basketball.team
)
end
+-----------+------------+
| records | time |
+-----------+------------+
| 100 | 0.91s |
| 1,000 | 1.19s |
| 10,000 | 4.37s |
| 100,000 | 42.48s |
+-----------+------------+
# Sets the locale to "Simplified Chinese":
Faker::Config.locale = 'zh-CN'

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store