开发者

rails equivalent of sql 'in ' operator

开发者 https://www.devze.com 2023-02-19 22:48 出处:网络
let\'s say that we have models, A, B, and C A is 1:N to B B is 1:N to C How would I use a query开发者_开发百科 to return the subset of C such that the owner of each C is one of the Bs owned by A?

let's say that we have models, A, B, and C

A is 1:N to B

B is 1:N to C

How would I use a query开发者_开发百科 to return the subset of C such that the owner of each C is one of the Bs owned by A?

essentially How to specify multiple values in where with AR query interface in rails3 but that's unanswered


You have to do a :through association:

A has_one C, :through => B

and then you would be able to do A.C

0

精彩评论

暂无评论...
验证码 换一张
取 消