[LRUG] association finder query problem
Matthew Rudy Jacobs
matthewrudyjacobs at gmail.com
Sun May 25 05:36:56 PDT 2008
oh wow,
that's awesome.
Never seen it before.
:joins => :association,
feels like there should be a way of giving it as "AS" param, though
2008/5/25 Pratik Naik <pratik at thinkwares.com>:
> Try :
>
> Monitor.find :all, :joins => [:features, :features], :conditions =>
> ["features.name = ? AND features_items.name = ?", 'white', 'big']
>
> On Sat, May 24, 2008 at 8:26 PM, Xin Zheng <xin at zenpow.com> wrote:
> > 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
> > _______________________________________________
> > Chat mailing list
> > Chat at lists.lrug.org
> > http://lists.lrug.org/listinfo.cgi/chat-lrug.org
> >
> >
>
>
>
> --
> http://m.onkey.org
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20080525/3779e172/attachment-0003.html>
More information about the Chat
mailing list