Is it possible to set some configuration variables in production.rb
dynamically using values from the database?
I'm building a multi-tenant app and each tenant has some environment specific information that needs to be set dynamically.
For example:
// production.rb
config.action_mailer.default_url_options = { :host => current_tenant.domain }
The current_tenant
is a helper method is defined in ApplicationHelper
so can't be accessed in production.rb
Here is current_tenant
:
// application_helper.rb
def current_tenant
@current_tenant ||= Tenant.find_by(domain: Apartment::Tenant.current)
end
If not, is it possible to dynamically create secrets.yml
using DB data? Since then I would be able to use ENV
in production.rb
Maybe you can try this instead: Create a helper method for your emails:
In your mailer, define the @tenant
Then in your email view use it