Allowing multiple databases to connect to the same project and still use ActiveRecord to perform operations on the models
Add this line to your application's Gemfile:
gem 'multi_tenancy_database'
And then execute:
$ bundle
Or install it yourself as:
$ gem install multi_tenancy_database
In this example, we’ll have a separate database for our e-commerce school that we’ll call school.
multi_tenancy_database -n school -a postgresql
rails school:db:create
rails g school_model user first_name:string last_name:string
rails g school_migration AddPhoneFieldToUser phone:string
rails school:db:migrate