[LRUG] association finder query problem

Xin Zheng xin at zenpow.com
Sat May 24 12:26:36 PDT 2008


Hi Guys,

For the life of me I can't figure this out. I think it requires a MySQL
solution than Rails. Anyway, here's my problem illustrated

Models:

Monitor (computer monitors)
has_many :features

Feature:
name = [big, small, black, white]

I want to find a Monitor that is BOTH white and big.

My first shot at this:
find(:all, :include => :features, :conditions => ["name IN ('white',
'big')" )

But this query will find Monitors that's EITHER white or big.

Can anyone help at all?

Xin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20080524/091f7abc/attachment.html>


More information about the Chat mailing list