Acts_as_ferret with has_many :through relationships?

I am currently using acts_as_ferret to search on a Posts table (title
and content fields). These posts also have tags (with has_many :tags,
:through => :questions_tags). I can’t figure out how to get
acts_as_ferret to work with that relationship and allow searching of
title, content, And tags at the same time (with the ability to set
boost as well). Can this be done?

On Thu, Sep 14, 2006 at 06:08:37AM +0200, Jeff Cabaniss wrote:

I am currently using acts_as_ferret to search on a Posts table (title
and content fields). These posts also have tags (with has_many :tags,
:through => :questions_tags). I can’t figure out how to get
acts_as_ferret to work with that relationship and allow searching of
title, content, And tags at the same time (with the ability to set
boost as well). Can this be done?

yeah, define a method that returns a string containing all tags, and
index that:

acts_as_ferret :fields => {
:title => { :boost => 2 },
:content => {},
:tag_string => {}
}

def tag_string
tags.collect { |t| t.name }.join(’ ')
end

Jens


webit! Gesellschaft für neue Medien mbH www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer [email protected]
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66