diff --git a/db/seeds.rb b/db/seeds.rb index 4fbd6ed..d161ab0 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,9 +1,22 @@ # This file should ensure the existence of records required to run the application in every environment (production, # development, test). The code here should be idempotent so that it can be executed at any point in every environment. # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). -# -# Example: -# -# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| -# MovieGenre.find_or_create_by!(name: genre_name) -# end + +if Rails.env.development? + puts "Seeding base users..." + + roles = User.roles.keys + + roles.each do |role| + email = "#{role}@zenrunner.com" + + User.find_or_create_by!(email: email) do |user| + user.name = "#{role.capitalize} User" + user.password = "password123" + user.password_confirmation = "password123" + user.role = role + end + end + + puts "Users seeded successfully!" +end diff --git a/setup_db.sh b/setup_db.sh new file mode 100755 index 0000000..4332cf6 --- /dev/null +++ b/setup_db.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +echo "Setting up the database using Docker..." + +bundle exec rails db:create db:migrate db:seed + +echo "Database setup complete!"