David Law
2009-Jan-20 21:11 UTC
[Facebooker-talk] alias_method_chain in Facebooker Causing Stack Level Too Deep
I installed the Facebooker plugin and upon placing it on a staging server, I keep running into stack level too deep errors. It seems to stem from Facebooker using alias_method_chain to override some of the ActionController methods. I believe it''s getting loaded twice causing confusion. I''ve tried various methods include wrapping a unless respond_to?(:method) around the alias_method_chain call to keep it from being called twice. However, none of this has worked? Has anyone run into this problem and found a remedy? I know alias_method_chain is a pretty popular way to override methods, so I can''t imagine this being the first instance of alias_method_chain causing this problem. Here is some of the sample code I''m looking to fix: module ::ActionController class Base def self.inherited_with_facebooker(subclass) inherited_without_facebooker(subclass) if subclass.to_s == "ApplicationController" subclass.send(:include,Facebooker::Rails::Controller) subclass.helper Facebooker::Rails::Helpers end end class << self unless ActionController::Base.respond_to? (:inherited_with_facebooker) alias_method_chain :inherited, :facebooker end end end end Here you can see the method inherited has been aliased to inherited_with_facebooker and inherited_without_facebooker has been aliased to inherited. However, when the method is called inherited_without_facebooker goes into an endless recursive call which results in a stack level too deep error. I tried to prevent alias_method_chain from being called twice (which is what I suspect the problem being) by checking if inherited_with_facebooker already exists. It has not seemed to fix the problem. Does anyone else have a possible solution I may try. Thanks again! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20090120/6c5ba37e/attachment.html>