My environment: Ruby 1.9.2p290, Rails 3.0.9 and RubyGem 1.8.8
unfortunately I have an issue when come across multiple database.
The situation is this: I have two model connect with two different
database and also establishing association between each other.
database connection specifying in each model, look likes
class Visit < ActiveRecord::Base
class Patient < ActiveRecord::Base
I got an error when meet following scenario
@visits = Visit.joins(:patient)
Errors: Mysql2::Error: Table ‘lab.patients’ doesn’t exist: SELECT
visits INNER JOIN
Here ‘patients’ table is in ‘main’ database and ‘visits’ table in ‘lab’
I doubt when executing the code, that Rails is considering ‘patients’
table is part of ‘lab’ database [which holds ‘visits’ table].