On Tue, May 08, 2007 at 05:02:40AM +0200, Antti Akonniemi
wrote:> Hi,
>
> Could you please explain the :limit to me? I thought I knew what it was
> but now it seems I''ve misunderstood something.
>
> >> Fooditem.find_by_contents("*quark*", {:limit => 10},
{:conditions => ["origin = ?", "fda"]}).length
> => 1
> >> Fooditem.find_by_contents("*quark*", {:limit =>
2000000}, {:conditions => ["origin = ?", "fda"]}).length
> => 8
>
>
> So is limit actually limiting the results before conditions?
yes, the limit option you''re using (in the first options hash) is
passed
to ferret while AR conditions are applied after running the
ferret search.
To get exact results you should use :limit => :all in the first hash and
put the ''real'' limit into the AR options hash.
Jens
--
Jens Kr?mer
webit! Gesellschaft f?r neue Medien mbH
Schnorrstra?e 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
kraemer at webit.de | www.webit.de
Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa