Reputation: 12092
Currently, I'm working on the application which is developed in rails 3* and ruby 1.9.3. I have configured some email address in the initializers section as YML file for each environments.
But, the requirement is keep on changing (but it'll happened every month 1 or 2 times) that need to add/remove the email address from the configuration. Hence, I need to restart the server on every changes. Because, I configured those address in the initializers.
Is there any better way to handle this situation?
Upvotes: 0
Views: 43
Reputation: 714
If you want to change the email without re-deploying / restarting the server, you can always create a Email
model and persist it to the database. By adding a current
field / column (boolean value) and a scope scope :current, -> { where(current: true) }
you can access the email via Email.current.first.address
, for instance. You might need to ensure that one and only one 'current' Email object ist present at any given time.
edit
config.cache_classes = true
in config/environments/production.rb
and specify the email in a constant outside the config directory (in some model or controller) like this EMAIL = '[email protected]'
. You would have to change the production code on each production machine, without a server restart. Sounds very hacky. Look into zero-downtime deploys à la Github for a more elegant solution. Redeploying should be cheap and painless.Upvotes: 1