How to connect multiple database on Ruby on Rails

1. config/database.yml edit this file as following:
default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: db/production.sqlite3

# ======== Өөр дата MYSQL =======-

tamir_development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: tamir_development
  pool: 5
  username: root
  password: tamir
  host: localhost
 

tamir_production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: tamir_production
  pool: 5
  username: root
  password: tamir
  host: localhost


2. app/model/jishee.rb use this like this
class Jishee < ActiveRecord::Base
    establish_connection "tamir_#{Rails.env}"

end


Comments