oh wow,<br>that's awesome.<br>Never seen it before.<br><br>:joins => :association,<br><br>feels like there should be a way of giving it as "AS" param, though<br><br><div class="gmail_quote">2008/5/25 Pratik Naik <<a href="mailto:pratik@thinkwares.com">pratik@thinkwares.com</a>>:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Try :<br>
<br>
Monitor.find :all, :joins => [:features, :features], :conditions =><br>
["<a href="http://features.name" target="_blank">features.name</a> = ? AND <a href="http://features_items.name" target="_blank">features_items.name</a> = ?", 'white', 'big']<br>
<div><div></div><div class="Wj3C7c"><br>
On Sat, May 24, 2008 at 8:26 PM, Xin Zheng <<a href="mailto:xin@zenpow.com">xin@zenpow.com</a>> wrote:<br>
> Hi Guys,<br>
><br>
> For the life of me I can't figure this out. I think it requires a MySQL<br>
> solution than Rails. Anyway, here's my problem illustrated<br>
><br>
> Models:<br>
><br>
> Monitor (computer monitors)<br>
> has_many :features<br>
><br>
> Feature:<br>
> name = [big, small, black, white]<br>
><br>
> I want to find a Monitor that is BOTH white and big.<br>
><br>
> My first shot at this:<br>
> find(:all, :include => :features, :conditions => ["name IN ('white',<br>
> 'big')" )<br>
><br>
> But this query will find Monitors that's EITHER white or big.<br>
><br>
> Can anyone help at all?<br>
><br>
> Xin<br>
</div></div><div class="Ih2E3d">> _______________________________________________<br>
> Chat mailing list<br>
> <a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br>
> <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
><br>
><br>
<br>
<br>
<br>
</div><font color="#888888">--<br>
<a href="http://m.onkey.org" target="_blank">http://m.onkey.org</a><br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
</div></div></blockquote></div><br>