# Find\_conditions in acts\_as\_ferret find\_by\_contents

**URL:** <https://www.ruby-forum.com/t/find-conditions-in-acts-as-ferret-find-by-contents/77348>\
**Category:** Ferret\
**Created:** [November 27, 2006, 7:14am UTC](https://www.ruby-forum.com/t/find-conditions-in-acts-as-ferret-find-by-contents/77348 "2006-11-27T07:14:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@daniel](https://www.ruby-forum.com/u/daniel)\
**Post date:** [November 27, 2006, 7:14am UTC](https://www.ruby-forum.com/t/find-conditions-in-acts-as-ferret-find-by-contents/77348/1 "2006-11-27T07:14:09Z")

</div>

Hi all,

Every time I try to add options for the find\_conditions argument of  
find\_by\_contents I get the following:

a = AnnotatedLink.find\_by\_contents(‘test’, {}, {:conditions =\>  
‘category\_id IS NOT NULL’})

> > NoMethodError: You have a nil object when you didn’t expect it!  
> > You might have expected an instance of Array.  
> > The error occured while evaluating nil.sort!  
> > from  
> > ./script/…/config/…/config/…/vendor/plugins/acts\_as\_ferret/lib/class\_methods.rb:288:in  
> > `find\_by\_contents’  
> > from (irb):1

I’m using rev 112 of acts\_as ferret and the latest version of ferret.  
Has anyone else had this problem?

Thanks!  
Daniel

---

<div class="post-metadata">

**Author:** ![daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@daniel](https://www.ruby-forum.com/u/daniel)\
**Post date:** [November 27, 2006, 7:29am UTC](https://www.ruby-forum.com/t/find-conditions-in-acts-as-ferret-find-by-contents/77348/2 "2006-11-27T07:29:09Z")

</div>

I think I found the problem. On line 470, this:

```
    def combine_conditions(conditions, additional_conditions)

```

should be this:

```
    def combine_conditions(conditions, *additional_conditions)

```

Furthermore, the rescue clause at 282 might be more usefull if it  
reraised the error

Thanks!

Daniel wrote:

> Hi all,
> 
> Every time I try to add options for the find\_conditions argument of  
> find\_by\_contents I get the following:
> 
> a = AnnotatedLink.find\_by\_contents(‘test’, {}, {:conditions =\>  
> ‘category\_id IS NOT NULL’})
> 
> > > NoMethodError: You have a nil object when you didn’t expect it!  
> > > You might have expected an instance of Array.  
> > > The error occured while evaluating nil.sort!  
> > > from  
> > > ./script/…/config/…/config/…/vendor/plugins/acts\_as\_ferret/lib/class\_methods.rb:288:in  
> > > `find\_by\_contents’  
> > > from (irb):1
> 
> I’m using rev 112 of acts\_as ferret and the latest version of ferret.  
> Has anyone else had this problem?
> 
> Thanks!  
> Daniel

---

<div class="post-metadata">

**Author:** ![daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@daniel](https://www.ruby-forum.com/u/daniel)\
**Post date:** [November 30, 2006, 3:14pm UTC](https://www.ruby-forum.com/t/find-conditions-in-acts-as-ferret-find-by-contents/77348/3 "2006-11-30T15:14:01Z")

</div>

On Mon, Nov 27, 2006 at 07:29:09AM +0100, Daniel wrote:

> I think I found the problem. On line 470, this:
> 
> ```
> def combine_conditions(conditions, additional_conditions)
> 
> ```
> 
> should be this:
> 
> ```
> def combine_conditions(conditions, *additional_conditions)
> 
> ```

correct, that way it works with a single string as conditions  
argument, too.

> Furthermore, the rescue clause at 282 might be more usefull if it  
> reraised the error

I changed the rescue to only catch RecordNotFound errors, and raised the  
log level to warn.

just committed.

Jens

–  
webit! Gesellschaft für neue Medien mbH [www.webit.de](http://www.webit.de)  
Dipl.-Wirtschaftsingenieur Jens Krämer removed\_email\_address@domain.invalid  
Schnorrstraße 76 Tel +49 351 46766 0  
D-01069 Dresden Fax +49 351 46766 66
