How do I configure the hostname for Rails ActionMailer? -
I am working on a fairly traditional forgotten password password - I email a link to a password change token to a user I want to click to change my password. I am emailing through a traditional action mailer.
If I were to tag a general link
Foo ,: verb = & gt; 'Bar',: Tokens = & gt; Token% & gt; I get a relative link - rather than an email is useless.
If I
: only_path = & gt; False , then these errors are saying that I need to set default_url_options [: host] . ActionController Docs means that you do this by overriding the #default_url_options methods in your controller. Definitely there is a configuration option to tell the rail what is that host name, it is without adding my own config file, parsing it etc.?
default_url_options config.action_mailer is available from And your environment should be set in the configuration file.
For example, config / environment / production.rb :
config.action_mailer.default_url_options = {: host => 'Www.yourdomain.com'} For local testing, config / environment / development.rb :
config Modify .action_mailer.default_url_options = {: host = & gt; '127.0.0.1',: Port = & gt; 3000} Again, suppose you have a named path called forgot_password_login , then you can generate login link url in your mailer using something like this Are:
forgot_password_login_url (: token = & gt; a7s8q15sk2 ... ')
Comments
Post a Comment