Topic: sql UNION type queries???

Is there such a solution in ruby/rails? I have had a look at :uniq - am I on the right track?

Re: sql UNION type queries???

There's find_by_sql. Or are you looking for a way to do this with "find" alone?

Railscasts - Free Ruby on Rails Screencasts

Re: sql UNION type queries???

I was hoping to see if it was possible with :find alone, rather than reverting to find_by_sql

Re: sql UNION type queries???

Not that I know of. you can always add find results together:

result = MyModel.find(...) + MyModel.find(...)

But that won't have the best performance.

Sometimes there are alternatives to doing a UNION but that's on a case-by-case basis and may require some changes to the schema.

Railscasts - Free Ruby on Rails Screencasts