Equivalent of belongs_to through in rails model -
What do I have to do? My argument is that I do not want to generate too many DB calls while crossing my model structure .
My example in pseudo-format:
is the producer / machine: In order to get all the people in the factory factory factory, I want to meet those manufacturers, where those manufacturers The factory is: factory
machines are present
The only way I can think, is to walk through the manufacturer. Machines. The factory, and the factory is saying. People (or people call a representative using the phone), but I call it a call.
Is there any way?
In your manufacturer
model you may have these relationships:
is_mini: machines # You already have one that is: the factories, through: In machines: people, people: factories
Assume that bob
is a manufacturer
. Now you can meet all the people in all the factories where machines of Bob
are present.
bob.people
Note that I have the people
model person
name Given when I tested it You should try to keep the name of your model as singular possible.
Comments
Post a Comment