diff --git a/lib/foodsoft_config.rb b/lib/foodsoft_config.rb index 33ad2524..71d9426c 100644 --- a/lib/foodsoft_config.rb +++ b/lib/foodsoft_config.rb @@ -60,10 +60,14 @@ class FoodsoftConfig # # FoodsoftConfig[:name] # => 'FC Test' # + # To avoid errors when the database is not yet setup (when loading + # the initial database schema), cached settings are only being read + # when the settings table exists. + # # @param key [String, Symbol] # @return [Object] Value of the key. def [](key) - if allowed_key?(key) + if RailsSettings::CachedSettings.table_exists? and allowed_key?(key) value = RailsSettings::CachedSettings["foodcoop.#{self.scope}.#{key}"] value = config[key] if value.nil? value @@ -146,10 +150,13 @@ class FoodsoftConfig end # When new options are introduced, put backward-compatible defaults here, so that - # configuration files that haven't been updated, still work as they did. + # configuration files that haven't been updated, still work as they did. This also + # makes sure that the configuration editor picks up the defaults. def set_missing config.replace({ use_nick: true, + use_wiki: true, + use_messages: true, use_apple_points: true, # English is the default language, and this makes it show up as default. default_locale: 'en', diff --git a/lib/foodsoft_messages/lib/foodsoft_messages.rb b/lib/foodsoft_messages/lib/foodsoft_messages.rb index 9cc7c4a6..08619383 100644 --- a/lib/foodsoft_messages/lib/foodsoft_messages.rb +++ b/lib/foodsoft_messages/lib/foodsoft_messages.rb @@ -4,8 +4,8 @@ require "deface" module FoodsoftMessages # Return whether messages are used or not. - # Enabled by default since it used to be part of the foodsoft core. + # Enabled by default in {FoodsoftConfig} since it used to be part of the foodsoft core. def self.enabled? - FoodsoftConfig[:use_messages] != false + FoodsoftConfig[:use_messages] end end diff --git a/lib/foodsoft_wiki/lib/foodsoft_wiki.rb b/lib/foodsoft_wiki/lib/foodsoft_wiki.rb index dc726e81..0d2aa77f 100644 --- a/lib/foodsoft_wiki/lib/foodsoft_wiki.rb +++ b/lib/foodsoft_wiki/lib/foodsoft_wiki.rb @@ -6,8 +6,8 @@ require 'foodsoft_wiki/engine' module FoodsoftWiki # Return whether the wiki is used or not. - # Enabled by default since it used to be part of the foodsoft core. + # Enabled by default in {FoodsoftConfig} since it used to be part of the foodsoft core. def self.enabled? - FoodsoftConfig[:use_wiki] != false + FoodsoftConfig[:use_wiki] end end