# Problems with Ferret and acts\_as\_ferret

**URL:** <https://www.ruby-forum.com/t/problems-with-ferret-and-acts-as-ferret/140771>\
**Category:** Rails\
**Created:** [June 18, 2008, 12:43pm UTC](https://www.ruby-forum.com/t/problems-with-ferret-and-acts-as-ferret/140771 "2008-06-18T12:43:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@adam](https://www.ruby-forum.com/u/adam)\
**Post date:** [June 18, 2008, 12:43pm UTC](https://www.ruby-forum.com/t/problems-with-ferret-and-acts-as-ferret/140771/1 "2008-06-18T12:43:00Z")

</div>

Hi all,

I’m trying to set up Ferret with the acts\_as\_ferret plugin and have  
run into some problems. I’m using a very basic setup as recommended by  
all the tutorials: install the ferret gem and acts\_as\_ferret plugin,  
put the line acts\_as\_ferret in my User class, then do something like  
this in my controller:

@users = User.find\_with\_ferret(params[:query])

This returns no results. The log shows no errors, just something like:

Query: test  
total hits: 0, results delivered: 0

No results are found for any query. I’ve tried deleting the Index  
directory and restarting the server, but this doesn’t help. I wonder  
if this is related to the fact that much of the documentation seems to  
be out of date - almost all tutorials refer to find\_by\_contents, which  
I believe has been replaced by find\_with\_ferret. Also, I installed the  
acts\_as\_ferret gem and ran aaf\_install - could this have caused  
problems? Has anyone successfully got this to work?

Many thanks,  
Adam

---

<div class="post-metadata">

**Author:** ![adam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@adam](https://www.ruby-forum.com/u/adam)\
**Post date:** [June 18, 2008, 1:57pm UTC](https://www.ruby-forum.com/t/problems-with-ferret-and-acts-as-ferret/140771/2 "2008-06-18T13:57:33Z")

</div>

It works fine for me.  
maybe force a rebuild index in script/console:  
Model.rebuild\_index

and use @object.ferret\_update whenever you change something in a field  
that’s ferret indexed.

otherwise have a look at acts\_at\_ferret.log in the log folder…

---

<div class="post-metadata">

**Author:** ![adam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@adam](https://www.ruby-forum.com/u/adam)\
**Post date:** [June 18, 2008, 2:15pm UTC](https://www.ruby-forum.com/t/problems-with-ferret-and-acts-as-ferret/140771/3 "2008-06-18T14:15:42Z")

</div>

Thanks for the quick reply. There’s definately a problem with the  
indexing. In acts\_as\_ferret.log I’m repeatedly getting

[user] register class User with index user  
[user] refusing re-registration of class User

Also, in the index directory, the file segments is empty, and  
segments\_0 contains only the line

class\_name?

I tried using User.rebuild\_index from the console and it did appear to  
build an index - there are now files called segments\_oj and \_oi.cfs in  
the index directory which are not empty. However, User.find\_by\_ferret  
still returns no results. I’m pretty stumped!

---

<div class="post-metadata">

**Author:** ![adam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@adam](https://www.ruby-forum.com/u/adam)\
**Post date:** [June 18, 2008, 2:33pm UTC](https://www.ruby-forum.com/t/problems-with-ferret-and-acts-as-ferret/140771/4 "2008-06-18T14:33:19Z")

</div>

I don’t have much of an idea, since it worked for me easy enough.  
maybe you didn’t set it up properly?

acts\_as\_ferret :fields =\> {:name =\> {:boost =\> 3}, :description =\>  
{:boost =\> 2, :store =\> :no}, :tag\_list =\> {}},  
:index\_dir =\> File.join(RAILS\_ROOT, “public”,  
“index”)

this one is adding fields name and description  
plus the tag\_list (from acts\_as\_taggable)  
but as you see, it’s not doing much. the boos values are optional  
anyway

---

<div class="post-metadata">

**Author:** ![adam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@adam](https://www.ruby-forum.com/u/adam)\
**Post date:** [June 18, 2008, 4:07pm UTC](https://www.ruby-forum.com/t/problems-with-ferret-and-acts-as-ferret/140771/5 "2008-06-18T16:07:27Z")

</div>

Fixed! Looks like it was just a dodgy installation. I was using the  
plugin installer built in to Aptana Radrails, which I guess must be  
corrupt. When I removed it and did a manual install it worked fine.

Thanks for your help 🙂
