Skip to content

Commit 06c50c5

Browse files
committed
Merge branch 'following-users'
2 parents 282b365 + d616eb5 commit 06c50c5

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

db/seeds.rb

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1-
# This file should contain all the record creation needed to seed the database with its default values.
2-
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
3-
#
4-
# Examples:
5-
#
6-
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
7-
# Character.create(name: "Luke", movie: movies.first)
1+
# Create a main sample user.
2+
User.create!(name: "Example User",
3+
4+
password: "foobar",
5+
password_confirmation: "foobar",
6+
admin: true,
7+
activated: true,
8+
activated_at: Time.zone.now)
9+
10+
# Generate a bunch of additional users.
11+
99.times do |n|
12+
name = Faker::Name.name
13+
email = "example-#{n+1}@railstutorial.org"
14+
password = "password"
15+
User.create!(name: name,
16+
email: email,
17+
password: password,
18+
password_confirmation: password,
19+
activated: true,
20+
activated_at: Time.zone.now)
21+
end
22+
23+
# Generate microposts for a subset of users.
24+
users = User.order(:created_at).take(6)
25+
50.times do
26+
content = Faker::Lorem.sentence(word_count: 5)
27+
users.each { |user| user.microposts.create!(content: content) }
28+
end

0 commit comments

Comments
 (0)