diff options
author | Andrew Kampjes <a.kampjes@gmail.com> | 2014-10-25 23:14:05 +1300 |
---|---|---|
committer | Andrew Kampjes <a.kampjes@gmail.com> | 2015-08-14 08:05:11 +1200 |
commit | f0a3af209f021774f0f2360d8843a3f630312431 (patch) | |
tree | 4630f56d27d07f1322eaeb56a84c17c0b63ce643 /actionmailer | |
parent | e50fe85180648be0c4216bd0111f05be1df0988a (diff) | |
download | rails-f0a3af209f021774f0f2360d8843a3f630312431.tar.gz rails-f0a3af209f021774f0f2360d8843a3f630312431.tar.bz2 rails-f0a3af209f021774f0f2360d8843a3f630312431.zip |
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.
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/CHANGELOG.md | 5 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 2 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/railtie.rb | 5 |
3 files changed, 12 insertions, 0 deletions
diff --git a/actionmailer/CHANGELOG.md b/actionmailer/CHANGELOG.md index 7c1b0b215a..0ecb0235bc 100644 --- a/actionmailer/CHANGELOG.md +++ b/actionmailer/CHANGELOG.md @@ -1,3 +1,8 @@ +* `config.force_ssl = true` will set + `config.action_mailer.default_url_options = { protocol: 'https' }` + + *Andrew Kampjes* + * Add `config.action_mailer.deliver_later_queue_name` configuration to set the mailer queue name. 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 <tt>config.force_ssl</tt> 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 |