config: fix email assets not having the full URL domain prepended

When sending emails, the mailer doesn't have access to the request
host. It needs to infer it by itself.

For this we need two settings:

- action_mailer.default_url_options, to generate urls to routes
- action_mailer.asset_host, to generate full urls to assets

Only the first one of these settings was set in production.

Fix #2518
This commit is contained in:
Pierre de La Morinerie 2018-11-21 11:28:13 +00:00
parent 37af20b236
commit ac9a87f27b
2 changed files with 10 additions and 0 deletions

View file

@ -46,6 +46,13 @@ Rails.application.configure do
# Action Mailer settings
config.action_mailer.delivery_method = :letter_opener_web
# Configure default root URL for generating URLs to routes
config.action_mailer.default_url_options = {
host: 'localhost',
port: 3000
}
# Configure default root URL for email assets
config.action_mailer.asset_host = "http://" + ENV['APP_HOST']
Rails.application.routes.default_url_options = {
host: 'localhost',

View file

@ -81,10 +81,13 @@ Rails.application.configure do
config.action_mailer.delivery_method = :mailjet
end
# Configure default root URL for generating URLs to routes
config.action_mailer.default_url_options = {
protocol: :https,
host: ENV['APP_HOST']
}
# Configure default root URL for email assets
config.action_mailer.asset_host = "https://" + ENV['APP_HOST']
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).