# Stack level too deep, alias\_method\_chain and an alternative

**URL:** <https://www.ruby-forum.com/t/stack-level-too-deep-alias-method-chain-and-an-alternative/184789>\
**Category:** Engines\
**Created:** [March 8, 2010, 6:50pm UTC](https://www.ruby-forum.com/t/stack-level-too-deep-alias-method-chain-and-an-alternative/184789 "2010-03-08T18:50:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [March 8, 2010, 6:50pm UTC](https://www.ruby-forum.com/t/stack-level-too-deep-alias-method-chain-and-an-alternative/184789/1 "2010-03-08T18:50:22Z")

</div>

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: [rails\_engines\_asset\_mixin · GitHub](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
