Jeff Cabaniss
2006-Sep-14 04:08 UTC
[Ferret-talk] 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? -- Posted via http://www.ruby-forum.com/.
Jens Kraemer
2006-Sep-14 07:54 UTC
[Ferret-talk] acts_as_ferret with has_many :through relationships?
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 kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66