0
請參見下面加入了多個數據庫表的表不起作用
class City < ActiveRecord::Base
establish_connection :cities_db
self.table_name_prefix = "cities_db."
has_many :clients
end
class Client < ActiveRecord::Base
# default connection
belongs_to :city
self.table_name = "client"
def self.with_cities
joins(:city)
end
end
Client.with_cities # returns ActiveRecord::StatementInvalid: Mysql2::Error: Table 'cities_db.clients' doesn't exist: SELECT `city_db`.`cities`.* FROM `cities_db`.`cities` INNER JOIN `clients` ON `clients`.`city_id` = `cities_db`.`cities`.`id`
代碼是否有可能以某種方式解決這個問題?感謝您的提前!