François Beausoleil
2007-Apr-12 19:08 UTC
[Ferret-talk] Does Ferret have problems with #alias_method_chain ?
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/
Maybe Matching Threads
- alias_method_chain in Facebooker Causing Stack Level Too Deep
- alias_method_chain vs. redefined method with super
- acts_as_paranoid and alias_method_chain
- alias_method_chain and ActiveSupport::TestCase
- `alias_method_chain': undefined method `find' for class `ActiveRecord::Base' (NameError)