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.