Hi Rami,
could you have a look at your development.log and check what values
actuelly gets indexed for the post_comments field when you save the
post ?
Jens
On Fri, Jul 21, 2006 at 08:51:48AM +0200, Rami Bitar wrote:
> Using Ferret and the acts_as_ferret plugin, I would like to retrieve
> results based on models descended from a parent model:
>
> class Post < ActiveRecord::Base
>
> acts_as_ferret :fields => [ 'title',
> 'body',
> :post_author,
> :post_comments
> ]
> ...
>
> has_one :author
> has_many :comments
> end
>
> I would like to search all comments of a post and retrieve Post models
> as search results. Currently, searching across :author fields is
> achieved using:
>
> def post_author
> self.author.name
> end
>
> However, a similiar technique does not seem to work for the has_many
> relationship:
>
> def post_comments
> for comment in self.comments
> @comments << comment.body
> @comments << comment.name
> end
> @comments.join(" ")
> end
>
> Searching across author fields finds the correct Post. However, none of
> the comments seems to be indexed and/or associated with the correct Post
> so no search results are found. I would appreciate any help on this.
>
> Thanks!
>
> Rami
>
> --------
> Note: The post model is saved after comment changes are made in order
> for acts_as_ferret to index the Post. Also note that multi_search would
> not easily apply here since I know for certain I would like to retrieve
> the Post model, and not the Comment or Author model as search results.
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ferret-talk mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/ferret-talk
--
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