Answer the question
In order to leave comments, you need to log in
[[+content_image]]
How to modify SQL query using Rails relationships?
This is automatically generated
SELECT "users".* FROM "users" INNER JOIN "workspace_roots" ON "users"."id" = "workspace_roots"."user_id" WHERE "workspace_roots"."root_id" = ? [["root_id", 2]]
It is necessary to put another value instead of 2, despite the fact that this value is taken from another object accessible by reference.
Answer the question
In order to leave comments, you need to log in
User.joins(:workspace_roots).where(workspace_roots: { root_id: 5 })
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question