1

I'm trying to achieve something like this:

TransportOrder has many LoadingPlaces as loadings
TransportOrder has many LoadingPlaces as unloadings

I can not create two separate models UnloadingPlaces and LoadingPlaces because later I want to search trough LoadingPlaces for TransportOrders.

karlosos
  • 1,034
  • 9
  • 25
  • Possible duplicate of [Ruby on rails - Reference the same model twice?](https://stackoverflow.com/questions/2057210/ruby-on-rails-reference-the-same-model-twice) – Alvaro Inckot Jun 11 '18 at 13:20

1 Answers1

1

Try to use foreign key syntax, and specify the 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"
Yule
  • 9,668
  • 3
  • 51
  • 72
Alvaro Inckot
  • 695
  • 9
  • 29