# Changing code mixing order

**URL:** <https://www.ruby-forum.com/t/changing-code-mixing-order/131304>\
**Category:** Engines Development\
**Created:** [March 7, 2008, 8:49pm UTC](https://www.ruby-forum.com/t/changing-code-mixing-order/131304 "2008-03-07T20:49:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mateo\_murphy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ec9cab/32.png) [@mateo\_murphy](https://www.ruby-forum.com/u/mateo_murphy)\
**Post date:** [March 7, 2008, 8:49pm UTC](https://www.ruby-forum.com/t/changing-code-mixing-order/131304/1 "2008-03-07T20:49:15Z")

</div>

Hi all,

In my latest project, I had a need to have code in a plugin override  
the code in the app (rather than the usual way) so I modified a couple  
of files to allow that. I was wondering if this was a feature that  
anyone else was interested in? If so I could submit a patch.

There is one thing I wasn’t entirely sure about, however. In  
plugin.rb, in the add\_plugin\_view\_paths method, there’s the following  
line of code:

ActionController::Base.view\_paths.insert(1, view\_path) # push it  
just underneath the app

Is there a particular reason why the the view\_path is inserted right  
after the app’s, rather than at the end of the array?

thanks

mateo

---

<div class="post-metadata">

**Author:** ![mateo\_murphy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ec9cab/32.png) [@mateo\_murphy](https://www.ruby-forum.com/u/mateo_murphy)\
**Post date:** [March 7, 2008, 9:18pm UTC](https://www.ruby-forum.com/t/changing-code-mixing-order/131304/2 "2008-03-07T21:18:43Z")

</div>

I’m interested in this functionality. Specifically, I’m more interested  
in  
a decorator where I can insert links to my new plugin into existing  
views.  
That way I can make the UI intuitive, but I don’t have to hack the core  
app’s code.

---

<div class="post-metadata">

**Author:** ![mateo\_murphy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ec9cab/32.png) [@mateo\_murphy](https://www.ruby-forum.com/u/mateo_murphy)\
**Post date:** [March 8, 2008, 5:08am UTC](https://www.ruby-forum.com/t/changing-code-mixing-order/131304/3 "2008-03-08T05:08:22Z")

</div>

I’ve thought of doing exactly that, but I’m not sure adding the  
functionality into engines is the best idea. Maybe in a  
separate/complimentary plugin?

In any case, using hpricot [http://code.whytheluckystiff.net/hpricot/](http://code.whytheluckystiff.net/hpricot/)  
should make it pretty trivial

---

<div class="post-metadata">

**Author:** ![mateo\_murphy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ec9cab/32.png) [@mateo\_murphy](https://www.ruby-forum.com/u/mateo_murphy)\
**Post date:** [March 8, 2008, 11:40pm UTC](https://www.ruby-forum.com/t/changing-code-mixing-order/131304/4 "2008-03-08T23:40:48Z")

</div>

Hi,

I’ve written some code to do just that, but there are a couple of  
points I’m not certain about; for one, where should this decorator  
code exist? Right now I have it as a class within the relevant helper  
module (i.e. TestHelper::Decorator) where you write methods of the  
same name as the actions you want to manipulate. However I’m not  
entirely sure that’s the best approach… what do you think?

Apologies if this is not completely relevant to this list, we can take  
the discussion elsewhere if need be
