Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails RubyonRails-使用:包含在不同模式的模型中_Ruby On Rails_Include_Schema_Models - Fatal编程技术网

Ruby on rails RubyonRails-使用:包含在不同模式的模型中

Ruby on rails RubyonRails-使用:包含在不同模式的模型中,ruby-on-rails,include,schema,models,Ruby On Rails,Include,Schema,Models,我正在使用RubyonRails模型。我有两个属于两个不同模式的模型。两个模型具有父子关系。e、 g class Group < ActiveRecord::Base has_one :customer end class Customer < ActiveRecord::Base establish_connection "schema2" end 我得到了错误 “schema1.Customer”是一个未定义的名称,“因为它试图在schema1而不是schema2中查

我正在使用RubyonRails模型。我有两个属于两个不同模式的模型。两个模型具有父子关系。e、 g

class Group < ActiveRecord::Base
  has_one :customer
end

class Customer < ActiveRecord::Base
  establish_connection "schema2"
end
我得到了错误 “schema1.Customer”是一个未定义的名称,“因为它试图在schema1而不是schema2中查找客户”

如何更改此查询(或this:include)以指示客户在schema2中。我尝试将组中的has\u one关系中的class\u name添加为
有一个:customer,class\u name=>“customer”
,但它不能解决问题,我也会遇到同样的错误


有什么想法吗?

你不能。你只能单独加载它们:

@groups = self.paginate(:all, :page => currentpage, :per_page => per_page)
@customers = Customer.find(:all, :conditions => {:id => @groups.map(&:id)})
@groups = self.paginate(:all, :page => currentpage, :per_page => per_page)
@customers = Customer.find(:all, :conditions => {:id => @groups.map(&:id)})