On Thu, Feb 01, 2007 at 02:42:38AM +0100, Mark wrote:
> PROBLEM
> I have two models, Blog and BlogComment. When a blog is initially
> created, it has no comments. Upon creation, the title and body are
> automatically added to the ferret index and directly searchable.
> However, when a comment is added to a blog, that comment does not get
> added to the index and is therefore not ferretable. The desired behavior
> is that when a comment is added to a blog, that the comment be
> ferretable.
> 
> CURRENT SETUP
> Blog (id, title, body, user_id)
> BlogComment (id, blog_id, comment)
> 
> class Blog < ActiveRecord::Base
>   has_many :blog_comments, :dependent => :destroy
>   acts_as_ferret :additional_fields => [:blog_comments]
> 
>   def blog_comments
>     self.blog_comments.collect {|comment| comment.body }
>   end
> 
> end
> 
> class BlogComment < ActiveRecord::Base
>   belongs_to :blog
> end
> 
> CONTROLLER
> [..]
> if @blog.blog_comments << comment
>    do_something

adding
     @blog.ferret_update
here should do the trick.

> else
>    do_something
> 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

Reply via email to