我试图达到这样的目标:
TransportOrder has many LoadingPlaces as loadings
TransportOrder has many LoadingPlaces as unloadings
我无法创建两个单独的模型UnloadingPlaces和LoadingPlaces,因为稍后我想通过LoadingPlaces搜索TransportOrders。
答案 0 :(得分:1)
尝试使用外键语法,并指定class_name:
has_many :loadings, foreign_key: "traport_order_id", class_name: "TransportOrder"
has_many :unloadings, foreign_key: "traport_order_id_two", class_name: "TransportOrder"