8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'app/models/terrapop_configuration.rb', line 8
def self.before
unless defined? @@configuration
str = File.open(Rails.root.to_s + "/config/terrapop.yml", 'r') { |f| f.read }
str = ERB.new(str).result
@@configuration = YAML.load(str)
end
unless @@configuration.dig(APPLICATION, COUNTRIES).nil?
if @@configuration[APPLICATION][COUNTRIES][0] == :all
@@configuration[APPLICATION][COUNTRIES] = Country.order(:short_name).pluck(:short_name)
end
end
if defined? ENV['SERVER_NAME']
unless ENV['SERVER_NAME'].nil?
begin
setting = TerrapopSetting.where(name: 'server_name').first
setting = TerrapopSetting.new if setting.nil?
setting.data_will_change!
setting.data = {'value' => ENV['SERVER_NAME']}
setting.name = 'server_name'
setting.save
rescue
end
end
end
end
|