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?
            Asked
            
        
        
            Active
            
        
            Viewed 24 times
        
    0
            
            
        - 
                    http://stackoverflow.com/a/6126706/23915 – Unixmonkey Jul 13 '15 at 22:57
1 Answers
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
