Forum: Ferret Does Ferret have problems with #alias_method_chain ?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
3dd4b52a0946bd698b1d1635a46ea3a3?d=identicon&s=25 François Beausoleil (fbeausoleil)
on 2007-04-12 21:20
(Received via mailing list)
Hi all,

I have this in my class:
class Party < AR::B
  acts_as_ferret :store_class_name => true, :remote => true,
      :fields => ( rescue []) +

  class << self
    # #count is also defined, omitted for clarity
    def find_with_destroyed_scope(*args)
      with_destroyed_scope do

    alias_method_chain :find, :destroyed_scope

    def with_destroyed_scope(&block)
      raise "Called without a block" unless block_given?
      with_scope(:find => {:conditions => "destroyed_at IS NULL"}) do

When I start the Ferret server and subsequently query it, I always get
a stack level too deep exception.  The error is caused by having the
redefined #find called twice.

The only way I can prevent that error from occuring is by guarding the
block of alias_method_chain so it isn't executed if Party already
responds appropriately:

    unless Party.respond_to?(:find_without_destroyed_scope) then
      alias_method_chain :find, :destroyed_scope

I repeat, this only happens in the Ferret server.  Not my production
code, not my development code.  If I use a local index, I don't have
that problem.  The problem almost looks like the problem with #require
that does not normalize paths before determining if it already loaded
a particular file.

Can anyone reproduce this problem ?

Thanks !
François Beausoleil
This topic is locked and can not be replied to.