File tree Expand file tree Collapse file tree 1 file changed +28
-7
lines changed Expand file tree Collapse file tree 1 file changed +28
-7
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments