Ruby on rails RubyonRails-使用:包含在不同模式的模型中
我正在使用RubyonRails模型。我有两个属于两个不同模式的模型。两个模型具有父子关系。e、 gRuby 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中查
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)})