我有一个非常复杂的模型,它有许多附加列 - 大约40个,所以我将它们分成多个表:
business
business_details
我希望我不必创建BusinessDetails模型并使用Business has_one BusinessDetails关系。
如何通过模型业务将业务连接到business_details并访问它们?
答案 0 :(得分:3)
你在找这样的东西吗?
class BusinessDetails < ActiveRecord::Base
belongs_to :business
end
class Business < ActiveRecord::Base
has_one :business_details
delegate :bd_field1, :bd_field2, :to => :business_details, :allow_nil => true
end