Nested One-To-Many ActiveRecord Question

I have a set of one-to-many relationships, nested 4 deep. In other
table_A has_many table_B,
table_B belongs_to table_A, has_many table C,
table_C belongs_to table_B, has_many table D,
table_D belongs_to table_C

Now, I want to to find on table_A, based on criteria in table_D, and
I want to paginate it. And I need fields from all four tables in the
result set.
Does anyone know how I can go about this?

I know that this will work:

@table_A = Table_A .find_by_sql ("select * from table_A, table_B,
table_C, table_D where … ")
using joins and filters in the SQL statement, but I can’t really see
how use this with the Paginator, and it also seems really un-Rails-
like. The find_by_sql is returning a ton of stuff I don’t need, and
the SQL is server-specific.

Thanks in advance for your help,


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs