On 6 Apr., 10:51, Saurabh P. firstname.lastname@example.org
How to connect the specific table of another database (suppose table
name is Arthur and it is in database2, I’m working in database1)
How to connect database without making changes in database.yml file.
Any feedback appreciated,
Given that you have a single model (Person) that you want to retrieve
data from a table in another database, you’ld make an initializer that
you could call people_connection.rb and put something like this
:adapter => “mysql”,
:host => “localhost”,
:username => “someuser”,
:password => “secret”,
:database => “somedatabase”
This is covered in the documentation for ActiveRecord::Base:
http://api.rubyonrails.org/classes/ActiveRecord/Base.html See the
“Connection to multiple databases in different models” section.
Remember, Google is your friend, and always check the manual.