# Is engine for me or how do i solve this with engine?

**URL:** <https://www.ruby-forum.com/t/is-engine-for-me-or-how-do-i-solve-this-with-engine/93208>\
**Category:** Engines\
**Created:** [April 29, 2007, 9:06am UTC](https://www.ruby-forum.com/t/is-engine-for-me-or-how-do-i-solve-this-with-engine/93208 "2007-04-29T09:06:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Linn\_Hutchinson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ac8455/32.png) [@Linn\_Hutchinson](https://www.ruby-forum.com/u/Linn_Hutchinson)\
**Post date:** [April 29, 2007, 9:06am UTC](https://www.ruby-forum.com/t/is-engine-for-me-or-how-do-i-solve-this-with-engine/93208/1 "2007-04-29T09:06:10Z")

</div>

Hi:

I have many small rails app under i.e app1, app2, app3 these are all  
independent applications except they all uses “same database”. Now I was  
thinking I would make a “common app” which can become an engine. Which  
means I will need to drop the “common app” to all of my rails app under  
“vendor” correct? no? Just to clarify my understanding …

app1  
-vendor  
-common\_functionality\_app\_as\_engine  
app2  
-vendor  
-common\_functionality\_app\_as\_engine

How can I avoid the above situation i.e. have a one “common app” is it  
possible to have the common app the following way

-app1  
-app2  
-common\_functionality\_app\_as\_engine

and then in app1/config/enviornments.rb … I add some text to point  
that my app is located in /path/to/common\_app…

Is that possible? could you please tell me how? is this a via able  
approach? what are the downside?

Regards  
Linn

---

<div class="post-metadata">

**Author:** ![Linn\_Hutchinson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ac8455/32.png) [@Linn\_Hutchinson](https://www.ruby-forum.com/u/Linn_Hutchinson)\
**Post date:** [May 27, 2007, 5:08am UTC](https://www.ruby-forum.com/t/is-engine-for-me-or-how-do-i-solve-this-with-engine/93208/2 "2007-05-27T05:08:36Z")

</div>

Hi Linn,

Your description about using vendor is almost right. It would be  
vendor/plugins/common\_functionality\_app\_as\_engine

Yes, using engines is certainly possible if you use version control like  
subvesion. You would set up a subversion external to your engine in  
vendor/plugins. I suppose if you are in a unix environment you could  
use a an alias instead of an extern. I actually use the subversion  
external method to share code between my apps. It does mean you have to  
do svn update on each app that uses common\_functionality\_app\_as\_engine  
if you change common\_functionality\_app\_as\_engine.

Another way would be to modify the load path in environment.rb (ex  
[http://www.benjaminbooth.com/tableorbooth/2006/11/rails\_and\_load\_.html](http://www.benjaminbooth.com/tableorbooth/2006/11/rails_and_load_.html))  
and make all your apps include the common apps. The advantage of  
engines over this is engines makes it easier to modify your common  
functionality classes. With engines you can define a class with the  
same name if you local app/models (or controlers/views), and it is  
pretty smart about using yours or mixing your new methods in with the  
plugin’s files.

Similar to the last method you could use externs in  
app/models|controllers|views. Again it might be tricky to extend the  
base classes.

-Andrew

Linn Hutchinson wrote:

> Hi:
> 
> I have many small rails app under i.e app1, app2, app3 these are all  
> independent applications except they all uses “same database”. Now I was  
> thinking I would make a “common app” which can become an engine. Which  
> means I will need to drop the “common app” to all of my rails app under  
> “vendor” correct? no? Just to clarify my understanding …
> 
> app1  
> -vendor  
> -common\_functionality\_app\_as\_engine  
> app2  
> -vendor  
> -common\_functionality\_app\_as\_engine
> 
> How can I avoid the above situation i.e. have a one “common app” is it  
> possible to have the common app the following way
> 
> -app1  
> -app2  
> -common\_functionality\_app\_as\_engine
> 
> and then in app1/config/enviornments.rb … I add some text to point  
> that my app is located in /path/to/common\_app…
> 
> Is that possible? could you please tell me how? is this a via able  
> approach? what are the downside?
> 
> Regards  
> Linn
