1

我有一个相当复杂的模型,它有许多附加列 - 大约 40 个,所以我将它们分成多个表:

business
business_details

我希望我不必创建 BusinessDetails 模型并使用关系 Business has_one BusinessDetails。

如何将业务连接到 business_details 并通过模型业务访问两者?

4

1 回答 1

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
于 2012-05-10T13:17:20.643 回答