I’m wondering if there’s a way I can gather data from multiple tables
from the child table by using the paginate method?
I would have done it using select_by_sql but I need it to paginate.
My table structure is:
Records is a child of Date and Account
Date Account
| |
^ ^
Records
I want to be able to print a table using the Records controller that
will display child records dependent on a specific date/account. So I
need a condition from more than one table.
I would assume you could use the :joins option of the paginate method to
get
the tables you want. I’m not sure I understand you data structure
though.
Do you have a Record object that has a date_id property that is a
foreign
key to Date.id and an account_id that is a foreign key to Account.id?
So
then I think this would do it:
I would assume you could use the :joins option of the paginate method to
get
the tables you want. I’m not sure I understand you data structure
though.
Do you have a Record object that has a date_id property that is a
foreign
key to Date.id and an account_id that is a foreign key to Account.id?
So
then I think this would do it: