Forum: Rails Engines stack level too deep, alias_method_chain and an alternative

444c7d8579d3389a76c8497f5cb66c13?d=identicon&s=25 M.W. Mitchell (goodieboy)
on 2010-03-08 18:50
(Received via mailing list)
Hi

I've been running into some weird behavior with our engine app. Latest
Rails, latest Engines plugin. When turning config.reload_plugins = true,
the
first request to our application runs fine, then we get an error, "stack
trace too deep". The error is always coming from an asset tag helper. I
looked at the code for "module Engines::RailsExtensions::
AssetHelpers" and found that alias_method_chain is at work for providing
module method overrides. When I remove the Engines AssetHelpers methods
(comment them out) -- the error goes away, of course our asset href's
are
all incorrect (no plugin name), but this led me to an experiment that
solved
the problem. Instead of using alias_method_chain, why not just define
the
regular ActionView::Helpers::AssetTagHelper methods, then call "super"?
Obviously the way that the methods are mixed into ActionView would need
to
change, but this does the trick right here:

ActionView::Base.class_eval do
  include Engines::RailsExtensions::AssetHelpers
end

My entire fix can be found here: http://gist.github.com/325296

I know there are a few more places that Rails includes
ActionView::Helpers::AssetTagHelper, but not more than 3 or 4.

James, can I provide a "real" patch if you find this an acceptable
solution?

Matt
This topic is locked and can not be replied to.