Hi all,

I have this in my class:
class Party < AR::B
  acts_as_ferret :store_class_name => true, :remote => true,
      :fields => (self.content_columns.map(&:name) rescue []) +
%w(main_identifier)

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

    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
        yield
      end
    end
  end
end

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
    end

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
http://blog.teksol.info/
http://piston.rubyforge.org/
_______________________________________________
Ferret-talk mailing list
[EMAIL PROTECTED]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to