On Sat, Aug 26, 2006 at 01:29:17AM +1000, David Balmain wrote:
> On 8/26/06, Alastair Moore <[EMAIL PROTECTED]> wrote:
> > Hello guys,
> >
> > I'm pretty new to using AAF and am having a slight problem with using a
> > condition. I have the following code
> >
> > @results = SupplierProduct.find_by_contents(params[:search], :conditions
> > => ['area_id = ?', @area])
> >
> > and it seems the condition isn't being applied. Does anyone have any
> > pointers?
> >
> > Cheers,
> >
> > Alastair
> 
> I'm not sure if the find_by_contents method has a :contents parameter
> but even if it does, I'd personally do it just like this;
> 
>     @results = SupplierProduct.find_by_contents(params[:search] + "
> +area_id:[EMAIL PROTECTED]")

that of course works if :area_id is an indexed field.

If area_id is not indexed, the :conditions option can be used to limit 
the find call that retrieves the model instances via ActiveRecord. Note
that you might get less results than expected when using :conditions,
since AR filters records out that Ferret counted as a hit.

correct usage:

@results = SupplierProduct.find_by_contents(params[:search], {}, { :conditions 
=> [] })

the first hash is for ferret-related options (like :limit, :offset and
so on), the second for activeRecord options.

Jens


-- 
webit! Gesellschaft für neue Medien mbH          www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer       [EMAIL PROTECTED]
Schnorrstraße 76                         Tel +49 351 46766  0
D-01069 Dresden                          Fax +49 351 46766 66
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to