fix Setting.from_config with no env

test plan:
 * create a sms.yml, looking like:
Alltel: message.alltel.com
 * in script/console
 * CommunicationChannel.sms_carriers should return just Alltel

Change-Id: I7af78bc56d1ff083090ec8ab93c574dbe7a6b3da
Reviewed-on: https://gerrit.instructure.com/21841
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
This commit is contained in:
Cody Cutrer 2013-06-28 11:32:37 -06:00 committed by Brian Palmer
parent c0be3e7f0e
commit 8a20e403cc
1 changed files with 6 additions and 2 deletions

View File

@ -75,7 +75,10 @@ class Setting < ActiveRecord::Base
def self.from_config(config_name, with_rails_env=:current)
with_rails_env = Rails.env if with_rails_env == :current
return @@yaml_cache[config_name][with_rails_env] if @@yaml_cache[config_name] # if the config wasn't found it'll try again
if @@yaml_cache[config_name] # if the config wasn't found it'll try again
return @@yaml_cache[config_name] if !with_rails_env
return @@yaml_cache[config_name][with_rails_env]
end
config = nil
path = File.join(Rails.root, 'config', "#{config_name}.yml")
@ -94,6 +97,7 @@ class Setting < ActiveRecord::Base
end
end
@@yaml_cache[config_name] = config
config[with_rails_env] if config
config = config[with_rails_env] if config && with_rails_env
config
end
end