Hi Maxime, On Sat, Jul 08, 2006 at 12:13:53AM +0200, Maxime Curioni wrote: > I am using Ferret and acts_as_ferret, as my search back-end for my Rails > project. I have a question about using acts_as_ferret on a main table > that is linked to other tables by foreign keys. Is there a way to > include the information linked by the belongs_to keyword in the search > results ? > [..]
> My Rails models are then: > > class Post < ActiveRecord::Base > belongs_to :category > acts_as_ferret :fields => [ 'title', 'content' ] > end > > class Category < ActiveRecord::Base > has_many :posts > end > > > I would want to be able to change the following line > acts_as_ferret :fields => [ 'title', 'content' ] > to > acts_as_ferret :fields => [ 'title', 'content', 'category.name' > ] > > and have Ferret search for records specified by title, content and > category name. you could use acts_as_ferret :fields => [ 'title', 'content', :category_name] def category_name category.name end to achieve this. 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 _______________________________________________ Ferret-talk mailing list [email protected] http://rubyforge.org/mailman/listinfo/ferret-talk

