I have worked a bit with Django and I quite like its project/applications model : you can build a Django project by assembling one or more Django applications. These applications can be autonomous, or some applications can be built on top of other applications. An application can easily rely on another application's models, as well as its controllers (Django dudes call them "views") and even its views ("templates" in Django-speak).
I am now working on a relatively large scale Ruby on Rails project, and I am surprised to see that there is apparently no easy way to do the same thing in Rails. Basically, in Rails, one project = one application. Our project has started off as a huge monolithic app, and we are now trying to figure out how to split it into smaller chunks.
For example, our current application allows us to manage partners and contracts (among other things). I would like to have a "Partners" application which would manage our partners (address, contacts, etc.) and a "Contracts" application which would manage our contracts with our partners. The "Contracts" application would rely on the "Partners" application (but to avoid a circular dependency, I would like the "Partners" app to have no knowledge of the "Contracts" app).
For now, I see the following as the main options:
Thanks for your advices.
Since this is something I would also like to be able to do, I can offer four - incomplete and relatively untested (by me) "solutions":
In no particular order...
Use the Rails engines plugin, which apparently works with 2.2 now. This, to some or all extent, will likely rolled into Rails 2.3 (see below)
Switch to Merb, which has something called "slices" that might offer what you're looking for. Anyway, if this is correct (and who am I to doubt Yehuda Katz?) it'll all be the same thing one day anyway, which is cool.
Take a look at the engines functionality in Edge Rails ("Edge" is the latest committed but unreleased version, so it usually works but may not be 100% production quality yet).
Look into using namespaces in routes.rb - allocating an item within app
to a namespace means you can put it into a subdirectory within the relevant app
subdirectory, although this is perhaps less clean to having a separate set of Rails directories for each "application".
Of these, I have no experience of (2) because I'm tied (in infrastructure terms) to Rails, but that's OK, I like Rails. I'm planning to take look at (1) and maybe (3), because 2.3 may be released before I need to deploy my next major release, and I've tried (4), which works but is, well, fiddly and a little (to me) confusing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With