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

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

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)
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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs