From f0a3af209f021774f0f2360d8843a3f630312431 Mon Sep 17 00:00:00 2001 From: Andrew Kampjes Date: Sat, 25 Oct 2014 23:14:05 +1300 Subject: ActionMailer https on URL with force_ssl = true `config.force_ssl = true` will set config.action_mailer.default_url_options = { protocol: 'https' } If you have turned on force_ssl, and then gone to the effort of setting config.action_mailer.default_url_options = {host: 'example.com'} then you are probably pointing people back to your current app and want https on that too. --- actionmailer/lib/action_mailer/base.rb | 2 ++ actionmailer/lib/action_mailer/railtie.rb | 5 +++++ 2 files changed, 7 insertions(+) (limited to 'actionmailer/lib/action_mailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 6f49e130d8..14abbefbcc 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -132,6 +132,8 @@ module ActionMailer # # config.action_mailer.default_url_options = { host: "example.com" } # + # By default when config.force_ssl is true, URLs generated for hosts will use the HTTPS protocol. + # # = Sending mail # # Once a mailer action and template are defined, you can deliver your message or defer its creation and diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index bebcf4de01..fa707021c7 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -16,6 +16,11 @@ module ActionMailer paths = app.config.paths options = app.config.action_mailer + if app.config.force_ssl + options.default_url_options ||= {} + options.default_url_options[:protocol] ||= 'https' + end + options.assets_dir ||= paths["public"].first options.javascripts_dir ||= paths["public/javascripts"].first options.stylesheets_dir ||= paths["public/stylesheets"].first -- cgit v1.2.3