Config.action_mailer.default_url_options = { :host => }

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

  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 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

Use a url. :host => “localhost:3000” or :host => “mywebsite.com

Dieter L.
http://www.coder2000.ca

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs