Rails, using ActiveRecord to find all rows matching a parent row attribute
Posted
by randombits
on Stack Overflow
See other posts from Stack Overflow
or by randombits
Published on 2010-06-07T03:10:29Z
Indexed on
2010/06/07
3:22 UTC
Read the original article
Hit count: 220
I have a class Foo which has_many Bars. Foo has an attribute, some_id. I want to Retrieve all Bar instances where the Foo has some_id = N. In SQL this translates into something like:
select * from bar inner join foo on foo.id = bar.foo_id WHERE foo.some_id = N
© Stack Overflow or respective owner