Set the asset host based on default_url_options

We were duplicating the asset host and the URL host in all environments,
but we can make it so the asset host uses the URL host unless we
specifically set it.

Note that, inside the `ApplicationMailer`, the `root_url` method already
uses `default_url_options` to generate the URL.

In the rare case of CONSUL installations who have changed the asset
host, this change has no effect since they'll get a conflict in the
environment files when upgrading and they'll choose to use their own
asset host.
This commit is contained in:
Javi Martín
2022-10-06 13:08:35 +02:00
parent a729967e8a
commit 9812757332
6 changed files with 46 additions and 4 deletions

View File

@@ -70,7 +70,6 @@ Rails.application.configure do
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { host: Rails.application.secrets.server_name }
config.action_mailer.asset_host = "https://#{Rails.application.secrets.server_name}"
# Configure your SMTP service credentials in secrets.yml
if Rails.application.secrets.smtp_settings