Stack level too deep, alias_method_chain and an alternative


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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs