API de comptabilité horaire.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

seeds.rb 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. User.delete_all
  2. User.reset_pk_sequence
  3. Activity.delete_all
  4. Activity.reset_pk_sequence
  5. JoinedUserActivity.delete_all
  6. JoinedUserActivity.reset_pk_sequence
  7. Task.delete_all
  8. Task.reset_pk_sequence
  9. 10.times do |i|
  10. name = Faker::Name.first_name.downcase
  11. user = User.create! username: "#{name}", email: "#{name}@email.com", password: "azerty"
  12. puts "Created USER ##{i} - #{user.username}"
  13. 2.times do
  14. activity = Activity.create!(
  15. name: Faker::Science.element,
  16. client: Faker::Company.name,
  17. description: Faker::Company.catch_phrase,
  18. author_id: user.id
  19. )
  20. puts "Created ACTIVITY \"#{activity.name}\" for #{activity.client}"
  21. joined_user_activity = JoinedUserActivity.create!(
  22. user_id: user.id,
  23. activity_id: activity.id
  24. )
  25. puts "Created ASSOCIATION ##{joined_user_activity.id}"
  26. end
  27. end
  28. User.create! username: "admin", email: "admin@email.com", password: "azerty", admin: true
  29. puts "Created Admin"
  30. 30.times do |i|
  31. task = Task.create(
  32. name: Faker::Fantasy::Tolkien.character,
  33. description: Faker::Fantasy::Tolkien.poem,
  34. duration: rand(1..120),
  35. user_id: User.all.sample.id,
  36. activity_id: Activity.all.sample.id
  37. )
  38. puts "Created TASK ##{i} - #{task.name}"
  39. end