Forum: Ruby on Rails RE: best way to combine results from two tables

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
9fc9f31415f9384fbe7262fa916e16f5?d=identicon&s=25 Brian Corrigan (Guest)
on 2006-03-09 17:15
(Received via mailing list)
I think you can do this with a join....  Give me the code for both of
your tables..  Let me give it a shot :-)



[] On Behalf Of Larry White
Sent: Thursday, March 09, 2006 11:09 AM
Subject: Re: [Rails] best way to combine results from two tables

I was wondering about that (view-table equivalence). Also not sure how
to create a view that concatenates data from two tables (rather than
joining), but I posted on the postgresql list for that one.

Since I'm starting to think that rolling my own would mean i can't get
pagination to work, i will probably try the db way.

On 3/9/06, Brian Corrigan <> wrote:

I'm going to throw my .02 in on this one.

I'm a long time DBA, and in my opinion, some things are just better left
to the database as a view (as you stated), a stored procedure, or a
table returning function.  There are many many complex data operations
that will occur much faster if run natively on the database.
(Operations that require temp tables, and cubes, etc. come to mind)

At any rate, my guess is that rails would treat a view and a tables the
same way..


[] On Behalf Of Larry White
Sent: Wednesday, March 08, 2006 5:04 PM
Subject: Re: [Rails] best way to combine results from two tables

I've got the farmer table down :)

I'm going to try an implementation that selects from both tables and
merges the results in the controller.  In my application, I think I can
do this safely because there's a limited amount of current data (per
farmer).  Also going to try to create a pagination object manually on
the merged data.  I'll let you know how it turns out.

The only alternative i could think of is to merge all the data in a
single table as you suggested, possibly using updatable views to create
models for each of the subtypes, but that seems to add a lot of

On 3/8/06, Craig White <> wrote:

OK - in that case, I am definitely interested if someone takes the time
to explain because I am working on reports that need to iterate over a
lot of items in a different manner but similarly enough that I might
learn something useful.


ps...I still would have a 'farmers' table

On Wed, 2006-03-08 at 16:19 -0500, Larry White wrote:
> That might have been best, but the animals are very different. lots of

>         display it
>         > For my display I nneed something like this:
>         both
>         belongs_to :farmers
> _______________________________________________
> Rails mailing list

Rails mailing list
This topic is locked and can not be replied to.