如果标题不准确,我很难道歉,我很难将这个问题提炼成一行。我正在使用amoeba gem并尝试确定是否可以将重复模型与多个belongs_to关系相关联。
例如:
class Building < ActiveRecord::Base
has_many :floors
has_many :layout_groups
end
class Floor < ActiveRecord::Base
belongs_to :building
has_many :units
end
class Unit < ActiveRecord::Base
belongs_to :floor
has_many :layouts
end
class Layout < ActiveRecord::Base
belongs_to :unit
belongs_to :layout_group
end
class LayoutGroup < ActiveRecord::Base
belongs_to :building
has_many :layouts
end
如您所见,Layouts
属于Unit
和LayoutGroup
。如果我完全复制Building
,如何将layouts
与units
和layout_groups
相关联,同时确保两组layouts
在这个过程中没有创建?
我愿意使用非阿米巴溶液,我刚刚在那里提出建议。