Find_with_ferret :multi doesn't work

Hi people!

I’m a newbie in Ferret, writing from Uruguay :wink:
I found that acts_as_ferret is an excellent tool and I make it worked
with simple queries (with just 1 model).

But, I found problems when I tried to use it with multiple models. Here
I show how I use it, maybe I misunderstood something…

I have 2 modeles models that I want to search on: Article and NewsItem.

article.rb

require ‘acts_as_ferret’
class Article < ActiveRecord::Base

acts_as_ferret :store_class_name => true

end

news_item.rb

require ‘acts_as_ferret’
class NewsItem < ActiveRecord::Base

acts_as_ferret :store_class_name => true

end

Then when I want to make use of find_with_ferret in my controller, the
code looks like this:

class SearchResultController < ApplicationController
def index
unless params[:q].blank?
params[:page] = 1 unless params[:page]
@collection = Article.find_with_ferret params[:q], :page =>
params[:page], :per_page => 1, :multi => [ NewsItem ]
else
flash[:notice] = “Please provide a search query”
redirect_to root_path
end
end
end

Everything looks fine at this point… but, as I mentioned this code
doesn’t work, and the error that controller displays is the following:

RuntimeError in Search resultController#index
‘:store_class_name => true’ required for multi_search to work

Any thoughts?, Any comment would make the difference :wink:

Thank you very much!
marcelo

I think I had some problems with this, and for me, it may have been AAF
being confused on the input args. Try something like this:

acts_as_ferret({ :fields => {:field_name => { :store => :yes }},
:store_class_name => true })

making sure to include all of the parens and curly brackets. If that
works for you, then pare down from there until you get what you need.

Also, did you run this? I added a “ferret.rake” as follows and ran “rake
ferret:rebuild_all_indexes” from cmd line, it helped fix some problems.
This is mentioned in the Gotchas page on
http://projects.jkraemer.net/acts_as_ferret/wiki/gotchas:

namespace :ferret do

desc “Rebuild all Indexes”
task :rebuild_all_indexes => [:environment] do
%w(Model1 Model2 Model3).each { |s| s.constantize.rebuild_index }
end
end