I run a Rails app, and we\'re in the process of splitting out our signup process to a separate app. The signup app has its own separate database (for CMS and collecting prospect
We just used interpolation for this:
class ServiceModel < ActiveRecord::Base
establish_connection :"main_app_#{Rails.env}"
end
The funny :"main_app_"
syntax makes a symbol from a string. This could be also written "main_app_#{Rails.env}".to_sym
. In either case with Rails 4.1 this must be a symbol (under 3.2 we had just used a string).