multiple database connections with has_many through

后端 未结 2 1749
梦毁少年i
梦毁少年i 2021-02-09 02:48

How can I make a has_many through work with multiple database connections?

I have a database named \"master\" that holds the location information. That is updated fro

相关标签:
2条回答
  • 2021-02-09 03:10

    The answer works for me, but I use this version in my relation table:

    self.table_name = "master.locations"
    
    0 讨论(0)
  • 2021-02-09 03:13

    A friend answered this for me, and I figured it might be of some use to others.

    class Location < ActiveRecord::Base
      #establish_connection "master"
      def self.table_name() "master.locations" end
      has_many :places
      has_many :users, :through => :places
    end
    
    0 讨论(0)
提交回复
热议问题