From 234e0f35c5b35bca6740f54a71c0801d3c3ba730 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 17 Jan 2019 17:28:00 +0800 Subject: [PATCH] Fix the build. 6edf285c893fdca4584e73a7274febcd586c665b --- config/initializers/006-ensure_login_hint.rb | 36 +++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/config/initializers/006-ensure_login_hint.rb b/config/initializers/006-ensure_login_hint.rb index af583da87a6..d5c425980d9 100644 --- a/config/initializers/006-ensure_login_hint.rb +++ b/config/initializers/006-ensure_login_hint.rb @@ -1,23 +1,27 @@ # Some sanity checking so we don't count on an unindexed column on boot -if ActiveRecord::Base.connection.table_exists?(:users) && - User.limit(20).count < 20 && - User.where(admin: true).human_users.count == 0 +begin + if ActiveRecord::Base.connection.table_exists?(:users) && + User.limit(20).count < 20 && + User.where(admin: true).human_users.count == 0 - notice = - if GlobalSetting.developer_emails.blank? - "Congratulations, you installed Discourse! Unfortunately, no administrator emails were defined during setup, so finalizing the configuration may be difficult." - else - emails = GlobalSetting.developer_emails.split(",") - if emails.length > 1 - emails = emails[0..-2].join(', ') << " or #{emails[-1]} " + notice = + if GlobalSetting.developer_emails.blank? + "Congratulations, you installed Discourse! Unfortunately, no administrator emails were defined during setup, so finalizing the configuration may be difficult." else - emails = emails[0] + emails = GlobalSetting.developer_emails.split(",") + if emails.length > 1 + emails = emails[0..-2].join(', ') << " or #{emails[-1]} " + else + emails = emails[0] + end + "Congratulations, you installed Discourse! Register a new admin account with #{emails} to finalize configuration." end - "Congratulations, you installed Discourse! Register a new admin account with #{emails} to finalize configuration." - end - if notice != SiteSetting.global_notice - SiteSetting.global_notice = notice - SiteSetting.has_login_hint = true + if notice != SiteSetting.global_notice + SiteSetting.global_notice = notice + SiteSetting.has_login_hint = true + end end +rescue ActiveRecord::NoDatabaseError + # Database might not have been created end