-
Notifications
You must be signed in to change notification settings - Fork 24
/
production.rb
33 lines (25 loc) · 1.16 KB
/
production.rb
1
2
3
4
5
6
7
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
# Allow Rails serve static file by default, this can be disable on Nginx addon
gsub_file('config/environments/production.rb', "ENV['RAILS_SERVE_STATIC_FILES'].present?", 'true')
insert_into_file 'config/environments/production.rb', after: %r{config.action_mailer.perform_caching.+\n} do
<<-EOT
config.action_mailer.asset_host = ENV.fetch('MAILER_DEFAULT_HOST')
config.action_mailer.default_url_options = {
host: ENV.fetch('MAILER_DEFAULT_HOST'),
port: ENV.fetch('MAILER_DEFAULT_PORT')
}
EOT
end
# Remove the incorrect fallback configuration (was generated by Rails)
# https://github.com/ruby-i18n/i18n/releases/tag/v1.1.0
gsub_file('config/environments/production.rb', 'config.i18n.fallbacks = true', '')
# Adding the correct fallback configuration along with default locale and available locales
environment do
<<~EOT
# eg: AVAILABLE_LOCALES = 'en,th'
config.i18n.available_locales = ENV.fetch('AVAILABLE_LOCALES').split(',')
# eg: DEFAULT_LOCALE = 'en'
config.i18n.default_locale = ENV.fetch('DEFAULT_LOCALE')
# eg: FALLBACK_LOCALES = 'en,th'
config.i18n.fallbacks = ENV.fetch('FALLBACK_LOCALES').split(',')
EOT
end