ActsAsFerret.find not working - Help

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.

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 %>

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.

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?

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs