Topic: Acts_as_ferret Sitewide Search

The documentation recommends I put find conditions in my models. Thats all fine and good, but its definitely not DRY if I have to paste this in 10 different models to get sitewide search

def self.full_text_search(q, options = {})
   return nil if q.nil? or q==""
   default_options = {:limit => 10, :page => 1}
   options = default_options.merge options
   
   # get the offset based on what page we're on
   options[:offset] = options[:limit] * (options.delete(:page).to_i-1) 
   
   # now do the query with our options
   results = Member.find_by_contents(q, options)
   return [results.total_hits, results]
end

I have a feeling that I need to create some kind of helper file in my lib folder, I'm just not sure how to specify the class.

Re: Acts_as_ferret Sitewide Search

Solved. just needed to specify this in my model.

multi_search(query, additional_models = [], options = {})

Re: Acts_as_ferret Sitewide Search

Well my troubles are not over yet. I finally got AAF to play nice from the console but things arent going so well as I try to write my views. Nothing but nils are getting returned and I cant figure out why,

You can see the code I am dealing with here

Re: Acts_as_ferret Sitewide Search

what error are you getting?

Railscasts - Free Ruby on Rails Screencasts

Re: Acts_as_ferret Sitewide Search

Nevermind! I made the mistake of using form_for instead of setting form_tag.

Problem solved smile