|
@@ -1,7 +1,20 @@
|
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
|
+User.delete_all
|
|
2
|
+User.reset_pk_sequence
|
|
3
|
+Activity.delete_all
|
|
4
|
+Activity.reset_pk_sequence
|
|
5
|
+
|
|
6
|
+10.times do |i|
|
|
7
|
+ name = Faker::Name.first_name.downcase
|
|
8
|
+ user = User.create! username: "#{name}", email: "#{name}@email.com", password: "azerty"
|
|
9
|
+ puts "Created user ##{i} - #{user.username}"
|
|
10
|
+
|
|
11
|
+ 2.times do
|
|
12
|
+ activity = Activity.create!(
|
|
13
|
+ name: Faker::Science.element,
|
|
14
|
+ client: Faker::Company.name,
|
|
15
|
+ description: Faker::Company.catch_phrase,
|
|
16
|
+ author_id: user.id
|
|
17
|
+ )
|
|
18
|
+ puts "Created activity \"#{activity.name}\" for #{activity.client}"
|
|
19
|
+ end
|
|
20
|
+end
|