# ActsAsFerret.find not working - Help

**URL:** <https://www.ruby-forum.com/t/actsasferret-find-not-working-help/137173>\
**Category:** Ferret\
**Created:** [May 9, 2008, 5:42pm UTC](https://www.ruby-forum.com/t/actsasferret-find-not-working-help/137173 "2008-05-09T17:42:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nerb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/eb8c5e/32.png) [@nerb](https://www.ruby-forum.com/u/nerb)\
**Post date:** [May 9, 2008, 5:42pm UTC](https://www.ruby-forum.com/t/actsasferret-find-not-working-help/137173/1 "2008-05-09T17:42:37Z")

</div>

[http://opensoul.org/2008/4/29/using-shared-indexes-with-acts\_as\_ferret/comments/6038#comment-6038](http://opensoul.org/2008/4/29/using-shared-indexes-with-acts_as_ferret/comments/6038#comment-6038).  
In this tutorial, I’ve yet to get results back from the searches i’ve  
created.

Here is my code. I’m not sure what is wrong with it.

BACKGROUND - AAF was working fine on a single model search. I wanted to  
incorporate a multi model search. I found the url above, and it’s  
helped, but doesn’t go into enough detail. i.e., he skipped the easy  
stuff, and that is where most of us get hung up. or if not most of us,  
me at least.

CODE–

here is my aaf.rb, which i modified from the tutorial above for the  
three models i want to search:

ActsAsFerret::define\_index(‘shared’,  
:models =\> {  
Product =\> {:fields =\> [:name, :company]},  
User =\> {:fields =\> [:login]},  
Post =\> {:fields =\> [:title, :body]}  
},  
:ferret =\> {  
:default\_fields =\> [:name, :company, :login, :title, :body]  
}  
)

I’ve got a search field in layouts/application.html.erb

\<% form\_tag(searches\_path, :method =\> ‘get’) do %\>  
\<%= text\_field\_tag :q, params[:q], :id =\> :q, :style =\>  
“width:33%” %\>  
\<%= submit\_tag “Search!”, :name =\> nil %\>

next, this info is sent to the controller in searches\_controller.rb

def index  
@results = ActsAsFerret.find(params[:q], ‘shared’)  
end

The controller is then to pass @results to searches/index.html.erb

# Search Results
\<%= params.inspect %\> \<%= @results.inspect %\> \<% @results.each do |result| %\> \<%= render :partial =\> "search/#{dom\_class(result)}" %\> \<% end %\>

HERE IS WHERE THINGS GO NUTSY FOR ME… but everything works. :q is  
being passed. however, I put the @results.inspect in there to see if  
@results was actually bringing anything back. it returns an empty array  
[].

so in my way of thinking, an empty array means that nothing is found in  
the shared index, which was setup in aaf.rb.

from the tutorial, i modified the following aaf.rb file to my models,  
which loads everytime i restart mongrel.

Questions,----  
What am i doing wrong?  
Am I missing something from the way I’ve explained things?  
Can anyone help a guy get the correct views?  
Also, i know that ferret server really is for production, but should i  
uncomment the development info in the ferret\_server.rb file?

I think if we can get a simple multi search explanation down, complete  
with views, it’ll make aaf go even further then sphinx in the future.

---

<div class="post-metadata">

**Author:** ![nerb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/eb8c5e/32.png) [@nerb](https://www.ruby-forum.com/u/nerb)\
**Post date:** [May 9, 2008, 5:47pm UTC](https://www.ruby-forum.com/t/actsasferret-find-not-working-help/137173/2 "2008-05-09T17:47:36Z")

</div>

ooops forgot my views. Here are the views, they are simple, as i wanted  
to just see SOMETHING on my screen on a search.

in users/\_user.html.erb  
\<%= link\_to result.login, root\_url %\>

in products/\_product.html.erb  
\<%= link\_to result.name, root\_url %\>

in posts/\_post.html.erb  
\<%= link\_to result.title, root\_url %\>

---

<div class="post-metadata">

**Author:** ![nerb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/eb8c5e/32.png) [@nerb](https://www.ruby-forum.com/u/nerb)\
**Post date:** [May 9, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/actsasferret-find-not-working-help/137173/3 "2008-05-09T17:50:21Z")

</div>

Lastly -

in my index/development/shared directory…

at startup i only have two files

segments  
and  
segments\_0

After each search, this directory NEVER grows… making me think that  
the info in aaf.rb isn’t being passed the way it should.

---

<div class="post-metadata">

**Author:** ![nerb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/eb8c5e/32.png) [@nerb](https://www.ruby-forum.com/u/nerb)\
**Post date:** [May 11, 2008, 6:33pm UTC](https://www.ruby-forum.com/t/actsasferret-find-not-working-help/137173/4 "2008-05-11T18:33:43Z")

</div>

Phi Jam wrote:

> Lastly -
> 
> in my index/development/shared directory…
> 
> at startup i only have two files
> 
> segments  
> and  
> segments\_0
> 
> After each search, this directory NEVER grows… making me think that  
> the info in aaf.rb isn’t being passed the way it should.

Is this forum still active?

---

<div class="post-metadata">

**Author:** ![nerb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/eb8c5e/32.png) [@nerb](https://www.ruby-forum.com/u/nerb)\
**Post date:** [January 5, 2009, 9:33am UTC](https://www.ruby-forum.com/t/actsasferret-find-not-working-help/137173/5 "2009-01-05T09:33:56Z")

</div>

Phi Jam wrote:

> Lastly -
> 
> in my index/development/shared directory…
> 
> at startup i only have two files
> 
> segments  
> and  
> segments\_0
> 
> After each search, this directory NEVER grows… making me think that  
> the info in aaf.rb isn’t being passed the way it should.

You should do it in production mode.  
Or at least try to do script/ferret\_server start -e production
