views:

49

answers:

1

Is it possible to have a single Ruby on Rails installations have multiple applications, that share a common model?

For example, I want to have a frontend application, as well as backend administration console, but both share the same model.

This is similar to the way Symfony works in PHP.

Thanks in advance!

+1  A: 

The easiest way to have admin panel is to use namespaces. You just put all admin stuff to admin namespace. It is very common practice.

On the other hand, if you want to have two (or more) applications sharing the same database and models it is quite easy. I have one project that has two RoR applications sharing the same database. So here are my thoughts about it:

  1. I put all migrations in my first project. It can be messy if you put all of them (or few here few there) in both applications. Then, after migration, you can copy schema.db to second project, or just us a symbolic link (in Unix-like systems) and don't care about it anymore.
  2. If you want to share some model in both application, then you can copy model file or use symbolic link. I used first method, because I didn't want to copy all related models that I don't use in second application.
  3. It works great. But in this case you also have to setup server for two applications. I've used different subdomains for both applications.

Hope it helps!

klew
I'll read up on namespaces, it sounds to be what I'm looking for. Excuse my terminology. :)
Joe Zephyr