On Tue, Nov 07, 2006 at 11:35:38AM +0100, Matthew Planchant wrote:
> Will this work with many-to-many relationships?
>
> For example:
>
> class Book < ActiveRecord::Base
> acts_as_ferret :additional_fields => [:topic_title]
>
> has_many :book_topics, :dependent => true
> has_many :topics, :through => :book_topics
>
> def topic_title
> return topic.title
> end
this won't work, as there is no method 'topic' in your Book class.
But you could index the titles of all topics:
acts_as_ferret :additional_fields => [:topic_titles]
def topic_titles
topics.collect { |topic| topic.title }.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
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk