Reputation: 237
In my rails appI have four models( say A, B, C, D, E and F)
I am trying to build query as follows
scope = A.joins(:b, { b: [:cs, {cs: [:d, {d: [:e,:f] } ] } ] })
But it is not working. The error message is schema cs (plural of c) does not exist
.
I am using Postgresql
.
Upvotes: 0
Views: 59
Reputation: 14402
Well, it seems like you're missing a B
reference (b_id
) in the C model. C
needs to know to which B
it belongs. After that, you can simplify the query to this:
A.joins(b: {cs: {d: [:e, :f]}})
Upvotes: 1