Tag: 构成了

Ruby on rails:将单个模型的2个引用添加到另一个模型

我想知道在rails 4.0的ruby中实现我的情况的正确方法。 可以说我有两个名为House and Order的模型。 我的订单表应该有两列引用房屋模型。 在这种情况下,我这两个模型之间的关系应该是什么? 注意:我不需要从房屋模型引用订单模型。 我希望在我的Order表中有这样的东西 t.references :house, as:from (this should create a column named from and should be of type integer, index of house table t.references :house, as:to (this should create a column named to and should be of type integer, index of house table 我想在订单模型中使用这种类型的关系,因为我想在我的订单中采用类似的房屋 … # order fields … […]