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

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.
6699cceb7fa4eb23580e149824edcbe2?d=identicon&s=25 M.W. M. (goodieboy)
on 2010-03-08 18:50
(Received via mailing list)

I've been running into some weird behavior with our engine app. Latest
Rails, latest Engines plugin. When turning config.reload_plugins = true,
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
all incorrect (no plugin name), but this led me to an experiment that
the problem. Instead of using alias_method_chain, why not just define
regular ActionView::Helpers::AssetTagHelper methods, then call "super"?
Obviously the way that the methods are mixed into ActionView would need
change, but this does the trick right here:

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

My entire fix can be found here:

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

This topic is locked and can not be replied to.