16

My entire app is https, no http.

If add the following to any of the views

I get a "edit user" linked to

https://localhost:3000/user/2/edit

But when I place the same line in a mailer view the email contains

http://localhost:3000/user/2/edit

Notice the "http" instead of "https"??

Using

rails 3.0.5 and ruby 1.8.7

Nutty Hiker
  • 163
  • 1
  • 4

2 Answers2

45

I believe that you have to put in your config/environments/production.rb:

config.action_mailer.default_url_options = {:protocol => 'https'}
Adobe
  • 12,967
  • 10
  • 85
  • 126
Roman
  • 13,100
  • 2
  • 47
  • 63
  • 1
    While this works for securing email links, it might not be the best idea. If you ever need to change domains, you're going to need to maintain two secure sites because otherwise all the HTTPS links to the old domain will break. It's better to have email links not be dependent on maintaining an old SSL Cert. – Amin Ariana Nov 26 '14 at 22:29
2

Editing my config/environments/development file with

host = "hostaddress.io"    
config.action_mailer.default_url_options = { host: host, protocol: 'https' }

worked for me on Rails 4.2.2.

tacos1998
  • 21
  • 4
  • 1
    If you're trying to get the Rails Tutorial sample app's account activation email links to work correctly, this is the way to go. – tacos1998 Mar 02 '16 at 15:01