# Iheritable/layered engines

**URL:** <https://www.ruby-forum.com/t/iheritable-layered-engines/83226>\
**Category:** Engines Development\
**Created:** [January 24, 2007, 2:31pm UTC](https://www.ruby-forum.com/t/iheritable-layered-engines/83226 "2007-01-24T14:31:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben\_wiseley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/45deac/32.png) [@ben\_wiseley](https://www.ruby-forum.com/u/ben_wiseley)\
**Post date:** [January 24, 2007, 2:31pm UTC](https://www.ruby-forum.com/t/iheritable-layered-engines/83226/1 "2007-01-24T14:31:47Z")

</div>

I’ve been using engines with great success doing custom shopping carts  
that  
rely on a core cart engine for 90% of their functionality. Every client  
wants something different and it’s been a breeze pulling this off with  
engines since the majority of the code never changes (warehouse,  
fulfillment, management layer, etc.). What I was wondering is, we often  
have clients who want two carts, that require very similar engine  
overrides  
(they want a public one and bulk marketing one, for example) and it’d be  
great to DRY in those situations.

Are there any suggestions for layering engines so they’d act as a sort  
of  
base-engine? Something like this:

CompanyCart-A-Rails App \< CompanyCartEngine \< CoreCartEngine

CompanyCart-B-Rails App \< CompanyCartEngine \< CoreCartEngine

Any way of pulling something like off? Can engines use engines in the  
same  
way Rails Apps can use engines?

-ben

---

<div class="post-metadata">

**Author:** ![ben\_wiseley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/45deac/32.png) [@ben\_wiseley](https://www.ruby-forum.com/u/ben_wiseley)\
**Post date:** [January 24, 2007, 3:24pm UTC](https://www.ruby-forum.com/t/iheritable-layered-engines/83226/2 "2007-01-24T15:24:53Z")

</div>

On 1/24/07, ben wiseley [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Are there any suggestions for layering engines so they’d act as a sort of  
> base-engine? Something like this:

There’s no reason why you can’t do this, if you’re careful and design  
your code sensibly. The key would be to ensure that your ‘base’ is  
loaded before any plugins, etc, that might override or customise it.

With 1.1.6 of the engines plugin, this would be done by ordering in  
the Engines.start method:

Engines.start :core, :client, :custom

With the upcoming 1.2 release, you control load order via the  
config.plugin array.
