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?
On Thu, Feb 01, 2007 at 02:54:41PM +0100, Mark wrote:
do_something
end
yeah, this should work, too. Even prettier from an architectural point
of view
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
Hi. i have the same problem, but my_instance.ferret_update doesn’t index
associated model fields on the console. Doesn’t ferret_update get called
after_save anyway?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.