# Re: Overriding code from one engine with another (extending

**URL:** <https://www.ruby-forum.com/t/re-overriding-code-from-one-engine-with-another-extending/71595>\
**Category:** Engines\
**Created:** [October 10, 2006, 6:45am UTC](https://www.ruby-forum.com/t/re-overriding-code-from-one-engine-with-another-extending/71595 "2006-10-10T06:45:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Estlin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6f9a4e/32.png) [@Brian\_Estlin](https://www.ruby-forum.com/u/Brian_Estlin)\
**Post date:** [October 10, 2006, 6:45am UTC](https://www.ruby-forum.com/t/re-overriding-code-from-one-engine-with-another-extending/71595/1 "2006-10-10T06:45:38Z")

</div>

> Suppose I want to make an engine that builds on another  
> engine. Extending engine code is pretty trivial in the application -  
> but what about in another engine?

I’m by no means an expert on engines, but I’ve been trying to do  
something similar and thought I’d share my experience.

Specifically, I customized the UserEngine and LoginEngine in an  
application for my company, then realized I wanted the same  
customizations in more than one app.

So I’ve been trying to make an Engine out of those customizations. And  
I think I’ve pretty much got it working. But not without some trouble.

1. Your application (not the plugin you’re creating) must not only load  
the plugins in the correct order in environment.rb, but must include the  
relevant modules in the right order in, say, ApplicationController (and  
ApplicationHelper if applicable). This is probably obvious to someone  
with more Engines experience, but it tripped me up for a while b/c I got  
weird errors, for example, my Permission class was defined but without  
any of the code from in UserEngine’s permission.rb.

2. Plugins might be loaded (or require’d) in other places. These have  
to be in order also. I ran into trouble trying to bootstrap the  
UserEngine because Permission.synchronize\_with\_controllers manually  
requires each controller class – it makes sure to require engines’  
controllers before the app’s controllers, but doesn’t specify an order  
(other than filesystem order) to look at the various engines. (I hacked  
it so it would require LoginEngine’s controllers first, then  
UserEngine’s, then other engines).

-Brian
