ferret and habtm

I was wondering if anyone had used ferret with an habtm relation?

Say you have books and authors
books habtm authors
authors habtm books

join table would be authors_books

I know in a 1 => m you can:
acts_as_ferret :fields => [:title, :author_name] on books
but how would you do something similar with the habtm?

Jon

You need to return what you want ferret to return to you when a search
is made.

The search results will return all books that contain the name of the
author, or authors. You could have a author_name as such,

def author_names
  search_string = ""
  authors = Authors.find_all_by_book(self)
  authors.each do | author |
    search_string << author.name << " "
  end
  search_string
end

You put this in the field to search and ferret will happily index it.

Serge Chevarie-Pelletier

tresero wrote: