views:

266

answers:

1

I would like to define a constant (like the admin-email-adress) depending on the environment. What is the easiest way to do this?

I'd like something like that, in development.rb (or test or production.rb):

ADMIN_EMAIL = "[email protected]"

And be able to access it by calling something like

ADMIN_EMAIL

Is there an easy way or do I have to do something like creating a module and initialize it and stuff (and in case you're wondering if I have any idea about this, unfortunately: I don't)

It works this way, but one has to restart the server, for the constants to take effect.

+5  A: 

In config/environments/, there are some configuration files that get executed based on what environment you're currently in. Try defining a constant in one of those.

zenazn
Ah, OK, I was trying to do that, but didn't realize I had to restart the server, so it would get initialized.
Roland Studer