fix bootup with specified redis database
(was making a call before AR connected) catch the failure in Setting.get and return the default but don't cache it Change-Id: I6a184a818f6ec12e036a468d31c5d8ebfae3068c Reviewed-on: https://gerrit.instructure.com/109703 Tested-by: Jenkins Reviewed-by: Simon Williams <simon@instructure.com> Product-Review: James Williams <jamesw@instructure.com> QA-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
620f971606
commit
106afe5be1
|
@ -28,11 +28,12 @@ class Setting < ActiveRecord::Base
|
|||
else
|
||||
begin
|
||||
from_db = Setting.where(name: name).first.try(:value)
|
||||
rescue ActiveRecord::StatementInvalid => e
|
||||
@@cache[name] = from_db || default.try(:to_s)
|
||||
rescue ActiveRecord::StatementInvalid, ActiveRecord::ConnectionNotEstablished => e
|
||||
# the db may not exist yet
|
||||
Rails.logger.warn("Unable to read setting: #{e}")
|
||||
Rails.logger.warn("Unable to read setting: #{e}") if Rails.logger
|
||||
default.try(:to_s)
|
||||
end
|
||||
@@cache[name] = from_db || default.try(:to_s)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue