Add user statuses and seed admin user

This commit is contained in:
2023-04-01 02:29:59 +02:00
parent d2fbacbf62
commit e29c060a39
5 changed files with 28 additions and 9 deletions

View File

@@ -1,7 +1,13 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
# Character.create(name: "Luke", movie: movies.first)
# This file should contain all the record creation needed to seed the database
# with its default values. The data can then be loaded with the
# bin/rails db:seed
# command (or created alongside the database with db:setup).
# Seeding process should be idempotent.
User.transaction do
User.find_or_create_by!(status: :admin) do |user|
user.email = Rails.configuration.admin
user.password = 'admin'
puts "Admin account '#{user.email}' created with default password '#{user.password}'"
end
end