ActiveRecord model that uses two tables (kind of like UNION in SQL)

Hi,

I'm sitting here pondering about how to solve this DB/AR related
problem. Being new to RoR it's kind of difficult as I DO know how to
use the tools below the surface, but not all of the ActiveRecord Super
Powers.

What I'd like to do, is search several tables using a finder. I just
want to search the title field in this case. In SQL I would do it like
this:

You an always do the SQL and get back an array of hashes. Then use
those hashes as you see fit. It is not "Object Oriented" but it is
much faster and clearer (if you know SQL). Use AR for what it is good
for (CRUD and simple navigation), use SQL for what it is good for
(complex queries, subqueries, etc). Do not be afraid to use multiple
tools. Not everything is a nail. (Not that you were suggesting
such).

Michael

Thanks for that very pragmatic answer Michael! After you replied I
went to dig into the Agile Rails book, and DHH says the same thing -
and I didn't remember it. Hahah!
I've now created an extension that does these types of queries. Works
like a charm!

Thanks!

/JS

JS wrote:

Thanks for that very pragmatic answer Michael! After you replied I
went to dig into the Agile Rails book, and DHH says the same thing -
and I didn't remember it. Hahah!
I've now created an extension that does these types of queries. Works
like a charm!

Thanks!

/JS

Hi, can you post the way you made that extension ? I mean, did you
created a new model, or it's inside /lib or is a plugin ?

Thanks!