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

Can someone recommend a good approach to automatically updating the
index when a comment is added?

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to