ruby on rails - Multi-tenant app with custom domains: how to populate tenant specific data in initializers and mailers? -


i'm creating multi-tenant app uses devise authentication, has initializer file set app specific information.

i'd use tenant's domain information in mailers.

what's best way store information , populate in initializers , mailers?

you should not have tenant specific information including mailer information in file. natural thing store information in database table. if setup multi-tenant app, database data each tenant separate other tenants.

for example have table tenantinformation , put tenant specific information mailer connection string inside. , depending of rails verision can set mailer connection option dinamicaly before sending email :delivery_method_options check: http://edgeguides.rubyonrails.org/action_mailer_basics.html

you can use existing solutions https://github.com/influitive/apartment easier work tenants.


Comments