From 58c3cdc102ab3a6a0eea36c9ede7ce84fddc7cbf Mon Sep 17 00:00:00 2001 From: Filip Stybel Date: Thu, 6 Feb 2020 14:32:35 +0100 Subject: [PATCH] Create one user with assigned role per each of the user roles in seeds. --- db/seeds.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index e757cd9..7952714 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -10,10 +10,12 @@ default_password = '12345678' -user = - { - email: 'user_0@example.com', - password: default_password +User::ROLES.each do |role_name| + user_attributes = { + email: "user_#{role_name}@example.com", + password: default_password, + role: role_name } - -User.create(user) \ No newline at end of file + user = User.create!(user_attributes) + puts 'Created user: ' + user.email +end \ No newline at end of file