Question

Please can someone point me in the right direction for what I'm sure is a simple problem, but is causing me to go round in circles.I have three domains

  1. .com

  2. .com.au

  3. .co.nz

    I'm trying to keep a single code base for maintenance.

I've done some manual localisation work to change titles, contact details etc based on the url, using request.original_url and stripping out the relevant parts and setting some constants in the application controller (SITE, EMAIL, TELEPHONE etc).

It all works fine, except for my config.action_mailer.smtp_settings in the production.rb.

These obviously should change so the localised email account is used (info@...com or .com.au etc) but

I can't get the constants to be initialised before the environment is loaded. It makes perfect sense why it's not working, but I have no idea how to fix it.

I've tried putting it in initializers, the application.rb and setting it in the production.rb itself. If I move the code anywhere out of the application controller I get a no method error on request.original_url.

Is there a way of pulling out mailer settings so they can be exposed to variables? Or is the production.rb loaded at app start up and after that is unaffected by the end user.

Also, even though the language is remaining the same should I look at i18n for manipulating the site for these features? or is it not worth the effort for the few variables I want to change.

Thanks in advance.

Was it helpful?

Solution

You can just change settings in runtime:

ActionMailer::Base.smtp_settings[:host] = 'yourhostfromrequest'

OTHER TIPS

You could just change the constants in your mailers, since constants in Ruby are mutable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top