S
S
Semyon Pyatnitsky2017-05-09 21:15:10
ORM
Semyon Pyatnitsky, 2017-05-09 21:15:10

How to properly bind models via includes in rails5?

Hello! Which day I can not solve the problem with ORM. There are 2 models: clients, contacts, connected through the 3rd - workplace. In the controller I try to select all clients and their contacts through includes and nothing happens. it is clear from the request that the orm goes to the workplace model and selects everything that is needed, but it does not communicate with the contact model in any way. Help! In the old manner, I remembered that in yii2 and in laravel it was enough to write through ->with('contacts') and the orm built queries with 3 models. just in case, he showed how I go through the counterparties in the
9Sonmd2Y_to.jpg
81eS1b75cZM.jpgyrpy6NcAPcg.jpg
6WMuRJDqUYs.jpg
hXzef-umgFQ.jpg
GMZspf3CMac.jpg
GIT view

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kochergin, 2017-05-19
@k4ir05

And it doesn't throw any error? In order("ClientName ASC"), in my opinion, the table should also be specified, and references may need to be added . And .all is not needed there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question