Find_conditions in acts_as_ferret find_by_contents

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

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

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
Dipl.-Wirtschaftsingenieur Jens Krämer [email protected]
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66