# Config.action\_mailer.default\_url\_options = { :host =\> }

**URL:** <https://www.ruby-forum.com/t/config-action-mailer-default-url-options-host/184898>\
**Category:** Rails\
**Created:** [March 10, 2010, 6:44am UTC](https://www.ruby-forum.com/t/config-action-mailer-default-url-options-host/184898 "2010-03-10T06:44:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [March 10, 2010, 6:44am UTC](https://www.ruby-forum.com/t/config-action-mailer-default-url-options-host/184898/1 "2010-03-10T06:44:58Z")

</div>

Hi  
In my application I have a mail sending part in which a user get mail  
with a link to activate his account. What I am currently doing is as a  
part of test I created a staging environment And in  
config/environments/staging.rb I write like  
config.action\_mailer.default\_url\_options = { :host =\> “Ip\_address\_here”  
}

```
 It is working fine And the user get a mail with content say to

```

click [http://192.168.0.12/activate/token](http://192.168.0.12/activate/token)

```
  Now a problem I find is suppose if have to test the same

```

application in another server in another location I have to edit the  
above to match the IP address of that machine And one more problem is  
if it is hosted in a public IP a user belong to that network get a mail  
like say Click  
[http://72.x.x.x/actiavate/token](http://72.x.x.x/actiavate/token) to activate. But it may not work from  
that network. So agin I have to edit and change it  
My question: Is this the standard way ?.Please advise me the correct  
approach to do this. Or Can I use ActionController::Request class for  
this

Thanks in advance  
Tom

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [March 10, 2010, 6:50am UTC](https://www.ruby-forum.com/t/config-action-mailer-default-url-options-host/184898/2 "2010-03-10T06:50:49Z")

</div>

Use a url. :host =\> “localhost:3000” or :host =\> “[mywebsite.com](http://mywebsite.com)”

Dieter L.  
[http://www.coder2000.ca](http://www.coder2000.ca)

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [March 10, 2010, 7:30am UTC](https://www.ruby-forum.com/t/config-action-mailer-default-url-options-host/184898/3 "2010-03-10T07:30:59Z")

</div>

Hi Dieter  
Your answer, if I undersood correctly is to specify like

config.action\_mailer.default\_url\_options = { :host =\> “localhost:3000” }

```
 in enviroment. This is what I do now. But my question is how to 

```

make it dynamic. Means some thing like

config.action\_mailer.default\_url\_options = { :host =\>  
request.host\_with\_port() }

```
  And also only at a single place to make it DRY

```

Tom
