maufl
maufl

Reputation: 379

How to organize development of Rails App and multiple Engines

It's hard to formulate the question actually so I just explain the situation.

I'm working on a application that consists of multiple sub applications. The main app just provides an navigation bar and some basic functionality like configuration of users and permissions while the sub applications provide the actual functionalities.

Now this is a Rails 2 application and the sub applications get embedded in frames, it's not really nice design and pretty complex to setup. Fortunately we have Engines now and that would be the saner solution for this application.

Until now everything lives in subversion and can be updated at once, shared code uses externals. We would like to move to git while we're at restructuring and refactoring. I've been searching the web the past few days about bundler, git submodules and git subtrees but I haven't found a good description how to properly manage a large project which consists of multiple Engines/Gems when you are developing on all of them the same time.

In particular I would like to be able to:

What I already thought about:

So has anybody of you a similar setup and how do you manage it to make updating and committing changes as easy as possible? Where do you put your Engine/Gem code on which the application depends?

TL;DR How do manage a large rails project which consists of multiple Engines and Gems?

Upvotes: 4

Views: 2196

Answers (2)

Martin
Martin

Reputation: 7723

We have a similar (but probably less complex) case at my company. What we do (as for now) and that could work for you too :

Put your Rails app in its own git repository. The various gems each get their own repository also (while it is possible to do otherwise, the "one gem = one git repository" will make your life easier).

Then in your Rails app Gemfile, you have several options

  • Default should be to refer each gem to its git repository (so that bundle will load them from there)
  • When working locally on some of the gems and the Rails app, either change the Gemfile to use the local path (http://gembundler.com/v1.2/gemfile.html) or better, by overriding the path locally (see: http://gembundler.com/v1.2/git.html). Be careful that those two options are different : the first one use the path, the second the local git repository (so a new uncommitted change will be visible by the first, not by the second).

For updating all your gems easily, I would create a small .sh script (just to launch the various clone or update operations, and the bundle install so that everything comes out clean), and commit it with the main app. I would also get a "standard folder organization" among the team (ie, that everyone use a base folder of their choice, with under it folders for the Rails app and each gem), to make the procedure easier.

I hope this can help or get you ideas (your question is quite complex and manifold, so I'm not 100 % sure this is what you are looking for).

Upvotes: 4

westonplatter
westonplatter

Reputation: 1495

How to manage your Gem dependencies?
Bundler via Gemfile.

How to manage your Engines?
Bundler via Gemfile.
Architect your Engines as Gems and provide their git repo location in your Gemfile. If you want examples, check out how to include the https://github.com/radar/forem gem in your Gemfile.

Also, this helped me learn Rails Engines, http://edgeguides.rubyonrails.org/engines.html.

Are you coming from Java Land?
Rails does have a learning curve, but not like the Java mountain cliff drop off.

Upvotes: 1

Related Questions