# Find\_with\_ferret conditions?

**URL:** <https://www.ruby-forum.com/t/find-with-ferret-conditions/144517>\
**Category:** Rails\
**Created:** [July 30, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/find-with-ferret-conditions/144517 "2008-07-30T15:59:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_CSHess](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@Sean\_CSHess](https://www.ruby-forum.com/u/Sean_CSHess)\
**Post date:** [July 30, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/find-with-ferret-conditions/144517/1 "2008-07-30T15:59:22Z")

</div>

Hello all,  
I’m trying to use acts\_as\_ferret to not only search for records, but to  
combine it with a filter function that filters those results by other  
things  
as well.

[http://pastie.textmate.org/244035](http://pastie.textmate.org/244035)

That gives an example of the Game.filter function. It is supposed to  
take a  
hash of parameters, and give you the filtered results. The parameters  
this  
is supposed to support are: players - the number of players, category -  
a  
habtm relationship, and q - a search query (on title or description).

First, if my approach to a filter function is totally wrong let me know.  
This seems like it should work, but {:players =\> 2} gives me “wrong  
number  
of bind variables (2 for 1) in: games.id in (?) and min\_players \<=  
:players  
and max\_players \>= :players”. I get the same type of error if I send it  
a  
category as well, or if I combine either with a search query.

The logger is outputting the hash for final\_conditions as I expect.  
Also,  
this works fine if I leave out the searching, so if I changed the last  
line  
to

results = Game.find(:all, :conditions =\> finalconditions, :include =\>  
includes)

It works, but leaves out the search query in the filter.

Thanks for your help!  
~sean

---

<div class="post-metadata">

**Author:** ![Sean\_CSHess](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@Sean\_CSHess](https://www.ruby-forum.com/u/Sean_CSHess)\
**Post date:** [July 31, 2008, 6:03am UTC](https://www.ruby-forum.com/t/find-with-ferret-conditions/144517/2 "2008-07-31T06:03:15Z")

</div>

Any ideas on this? Am I taking the wrong approach?
