From 2e2c7c56cbf804c639af3836898cbe1678866d98 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Tue, 30 Oct 2018 18:45:33 +0100 Subject: [PATCH] Move default_url_options set up to an initializer For some reason running `bundle exec rake db:migrate RAILS_ENV=staging` fails with: ``` rake aborted! NameError: uninitialized constant Spree::Config ``` Running `bundle exec rails server` for instance, does not. There must be a difference on the way a rake task and the rails commands load the app. Moving this configuration to an initializer, at the end of the initialization process, fixes it. The constant `Spree::Config` is already loaded. **This is preventing the release v1.22.0 from being staged and tested** --- config/environments/production.rb | 3 --- config/environments/staging.rb | 3 --- config/initializers/action_mailer.rb | 6 ++++++ 3 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 config/initializers/action_mailer.rb diff --git a/config/environments/production.rb b/config/environments/production.rb index 88c743071a..229221e118 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -30,9 +30,6 @@ Openfoodnetwork::Application.configure do # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = true - # Use https when creating links in emails - config.action_mailer.default_url_options = { protocol: 'https', host: Spree::Config[:site_url] } - # See everything in the log (default is :info) config.log_level = :info diff --git a/config/environments/staging.rb b/config/environments/staging.rb index f43d42f998..303d7d2913 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -30,9 +30,6 @@ Openfoodnetwork::Application.configure do # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = true - # Use https when creating links in emails - config.action_mailer.default_url_options = { protocol: 'https', host: Spree::Config[:site_url] } - # See everything in the log (default is :info) # config.log_level = :debug diff --git a/config/initializers/action_mailer.rb b/config/initializers/action_mailer.rb new file mode 100644 index 0000000000..cd2a638567 --- /dev/null +++ b/config/initializers/action_mailer.rb @@ -0,0 +1,6 @@ +ActionMailer::Base.configure do |config| + if Rails.env.production? || Rails.env.staging? + # Use https when creating links in emails + config.default_url_options = { protocol: 'https', host: Spree::Config[:site_url] } + end +end