ernie/meta_search — Issue #71: Search using join across multiple database
Author: jmaniv
Created: 2011-11-02 07:43:42+00:00
State: open

I also have exactly same problem experienced by 'timcreatewell' mentioned in https://github.com/ernie/meta_search/issues/69
I tried the solution provided and its not working

My environment: Ruby 1.9.2p290, Rails 3.0.9, meta_search 1.0.6
My models look likes
class Visit < ActiveRecord::Base
self.establish_connection "lab"
belongs_to :patient
end

class Patient < ActiveRecord::Base
self.establish_connection "main"
has_many :visits
end

I added
=> set_table_name "#{Patient.connection.current_database}.#{Patient.table_name}"
in the other database's model as forum discussion, I got undefined method `eq' for nil:NilClass.

Patient.arel_table results is

=> # Arel::Table:0xabcb7f4 @name="main.patients", @engine=Patient(Table doesn't exist), @columns=nil, @aliases=[], @table_alias=nil, @primary_key=nil

How to fix it ?
Thanks in advance,
Jmaniv