Proper way for deploying many applications sharing a common user database

Hi,

I know that it's possible to use multiple databases with Rails.
However most of the examples I have seen were for high availability. I
would like to learn if anyone has any experience with a shared
database among many rails applications. Such a case may make sense for
shared user information. Any ideas?

Thanks.

We use one database for a shared application which includes an ecommerce site, the associated admin site, and the orders site.

All you have to do is make sure your database.yml files match, and be sure to copy your models into each site. It works well, but....

It really violates the DRY principle. I'm not sure why our sites were set up like this, but the more I use it the more irritated I get when I run into an error because I didn't copy a model from site to site.

If you can figure out how to get past this, or it doesn't apply, then using one database shared between sites isn't too big of a deal.

Ersin Er wrote:

You could put your models and other shared parts of all these
applications in a plugin in a seperate repository and include that
plugin in your applications through svn:externals. That way, whenever
you deploy your apps, svn pulls the most recent versions of your
shared files.

I have not done anything like this yet (am planning on it for a future project), but I did just come across this in the api docs:

Connections are usually created through ActiveRecord::Base.establish_connection and retrieved by ActiveRecord::Base.connection. All classes inheriting from ActiveRecord::Base will use this connection. But you can also set a class-specific connection. For example, if Course is an ActiveRecord::Base, but resides in a different database, you can just say Course.establish_connection and Course and all its subclasses will use this connection instead.

This feature is implemented by keeping a connection pool in ActiveRecord::Base that is a Hash indexed by the class. If a connection is requested, the retrieve_connection method will go up the class-hierarchy until a connection is found in the connection pool.

Peace,

Phillip

What about creating a rails application to act as an authentication
service? Then use ActiveResource to authenticate your users from each
of your applications in place of ActiveRecord? I think that's the
approach I would take. Another option would be to use an LDAP server
for storing and authenticating users.

In other words use a Single Sign On (SSO) approach to authentication.
Another really good option would be to implement OpenID and forego the
whole username/password combination all together. I for one will be
very happy once the world really catches onto this. To have one single
source of identity for every site I use would be fantastic.

Just some ideas to think about. Either of these methods would be DRY
and very flexible.