How can I get the base url in an ActionMailer?
actionmailer, ruby-on-rails
Solution
Set the defult url option in `config/environments/production.rb`
config.action_mailer.default_url_options = { :host => 'your.app.com' }
and in mail template
the link should be
<%= link_to 'myapp', myapp_list_url %>
Hope this could help
You can refer the Action Mailer doc
Problem
I want to send out an email with a deep link back into my app, but I'd rather not have to hard-code the URL or else I have to switch it when I move from one environment to the next. How can I obtain the base url of a web app from within an ActionMailer? For example, I'd love to be able to have something like: ``` <%= base_uri %>listCreate?first=foo&second=bar ``` render something like the following in my testing environment: ``` http://localhost:30000/myApp/listCreate?first=foo&second=bar ``` and the following in production: ``` http://www.myDomain.com/myApp/listCreate?first=foo&second=bar ```