diff --git a/app/models/user.rb b/app/models/user.rb index 77cd5116a3..533f807e39 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -196,9 +196,10 @@ class User < ApplicationRecord end SYSTEM_USER_EMAIL = "bank@hackclub.com" + SYSTEM_USER_ID = 2891 def self.system_user - User.find_by!(email: SYSTEM_USER_EMAIL) + User.find!(SYSTEM_USER_ID) end after_save do diff --git a/db/seeds.rb b/db/seeds.rb index 8e53575c6f..ce523d2e40 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -13,10 +13,8 @@ user.make_admin! unless user.admin? -if User.find_by(email: User::SYSTEM_USER_EMAIL).nil? - admin = User.create!(email: User::SYSTEM_USER_EMAIL) - admin.make_admin! -end +admin = User.create_with(email: User::SYSTEM_USER_EMAIL).find_or_create_by!(id: User::SYSTEM_USER_ID) +admin.make_admin! # DEMO demo_event = Event.create_with(