# How to Affect Plugin Load Order

**URL:** <https://www.ruby-forum.com/t/how-to-affect-plugin-load-order/53278>\
**Category:** Rails\
**Created:** [January 31, 2006, 2:36am UTC](https://www.ruby-forum.com/t/how-to-affect-plugin-load-order/53278 "2006-01-31T02:36:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [January 31, 2006, 2:36am UTC](https://www.ruby-forum.com/t/how-to-affect-plugin-load-order/53278/1 "2006-01-31T02:36:26Z")

</div>

I’m using bundled\_resource, login\_engine, and a few other plugins. It  
appears Rails considers plugins in alphabetic order. Turns out that  
there is a particular order that will work and alphabetic ain’t it.

The login engine must be loaded first. Bundled resource then includes  
‘application\_helper’ and the application helper includes LoginEngine. If  
bundled\_resource is allowed to load first, when it includes  
‘application\_helper’ the include LoginEngine fails with an undefined  
constant.

Is there a way to change plugin load order?

Thanks

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [January 31, 2006, 4:17am UTC](https://www.ruby-forum.com/t/how-to-affect-plugin-load-order/53278/2 "2006-01-31T04:17:00Z")

</div>

On 1/30/06, Steve R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a way to change plugin load order?
> 
> Thanks

Why not just fudge the names a bit? a\_login\_engine will cause it to  
load first 🙂

–  
Rick O.  
[http://techno-weenie.net](http://techno-weenie.net)

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [January 31, 2006, 5:35am UTC](https://www.ruby-forum.com/t/how-to-affect-plugin-load-order/53278/3 "2006-01-31T05:35:20Z")

</div>

I actually did it the other way around: zbundled\_resource.

But seriously, we deal with dependencies all over the development  
process. Ruby Gems are good with dependencies, and other parts of Rails  
are. Isn’t there a cleaner way to deal with this?

Steve R.

Rick O. wrote:

> On 1/30/06, Steve R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Is there a way to change plugin load order?
> > 
> > Thanks
> 
> Why not just fudge the names a bit? a\_login\_engine will cause it to  
> load first 🙂
> 
> –  
> Rick O.  
> [http://techno-weenie.net](http://techno-weenie.net)

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [January 31, 2006, 6:07pm UTC](https://www.ruby-forum.com/t/how-to-affect-plugin-load-order/53278/4 "2006-01-31T18:07:07Z")

</div>

This issue isn’t really related to the fact that engines need to be  
‘started’, as the problem would occur with if the file being require’d  
at the top of application\_helper.rb was a part of any plugin that  
hadn’t been processed yet.

The next release of Rails should make things _slightly_ better,  
because as I recall I had a patch accepted which added all the plugin  
‘lib’ directories before performing any of the init.rb code. However  
I’m not sure if that code remains intact.

The ‘best’ way that I can think of to avoid this issue at the moment  
would be for plugins not to load files like application\_helper.  
However, I can perfectly understand why Duane has done this…

- james

On 1/31/06, Gerret A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> patching the rails source.
> 
> > > 
> > 
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [February 2, 2006, 3:27pm UTC](https://www.ruby-forum.com/t/how-to-affect-plugin-load-order/53278/5 "2006-02-02T15:27:03Z")

</div>

While the plugin load order hasn’t necessarily been fixed, I just  
want to mention that bundled\_resource no longer loads  
application\_helper, and therefore has no conflict with the engines  
plugin.

It turns out the fix was simple: include bundle helper modules in the  
ActionView::Base class instead of the ApplicationHelper class. Works  
like a charm 🙂

I wonder if engines could use this technique also? It might be nice  
for some functionality to be automagic so that no modification to  
ApplicationHelper is necessary.

Duane

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [January 31, 2006, 8:08am UTC](https://www.ruby-forum.com/t/how-to-affect-plugin-load-order/53278/6 "2006-01-31T08:08:36Z")

</div>

Steve,

the engines plugin requires you to call “start\_engine” for just this  
reason – if your engine depends on another plugin, there’s no way to  
guarantee that the dependency will be loaded before the engines  
plugin.

IIRC, the idea is for “start\_engine” to disappear as soon as rails  
supports user-defined plugin load order. So long story short, I don’t  
believe there’s a way to determine that load order atm, other than by  
patching the rails source.

cheers  
Gerret

---

<div class="post-metadata">

**Author:** ![cwd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@cwd](https://www.ruby-forum.com/u/cwd)\
**Post date:** [February 2, 2006, 3:42pm UTC](https://www.ruby-forum.com/t/how-to-affect-plugin-load-order/53278/7 "2006-02-02T15:42:12Z")

</div>

It’s something I’ve thought about, and engine developers are of course  
free to do (since engines are still just plugins). At the same time,  
though, I can’t help but feel it’s a bit wrong to slip so deep into  
the class heirarchy, though I’m not sure why.

Can someone please convince me that it’s a kosher thing to do? In all  
truth I would _love_ to remove the need to add includes to  
ApplicationControlller/Helper…

–

- J \*  
~
