API de comptabilité horaire.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

seeds.rb 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. 30.times do |i|
  29. task = Task.create(
  30. name: Faker::Fantasy::Tolkien.character,
  31. description: Faker::Fantasy::Tolkien.poem,
  32. user_id: User.all.sample.id,
  33. activity_id: Activity.all.sample.id
  34. )
  35. puts "Created TASK ##{i} - #{task.name}"
  36. end