0

I have two MySQL databases on a single host. I want to primarily use the first database and to refer to the second database for a single, specific table. All DB calls should refer to the first DB except for calls that reference this specific table. Is there a way to either forward DB requests to another DB or to adjust the configurations in rails to accommodate this?

Johnny Brofish
  • 105
  • 1
  • 1
  • 5

1 Answers1

1

you can use establish_connection in your class

class User < ActiveRecord::Base
    establish_connection(
      adapter: 'mysql2'
      encoding: 'utf8'
      pool: 5
      username: 'me'
      password: 'mypassword'
    )
end

You can find more details here

Moustafa Samir
  • 2,248
  • 1
  • 25
  • 32