Ersin Er
2007-Dec-28 13:50 UTC
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. -- Ersin Er --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sheryl Barrow
2007-Dec-28 14:44 UTC
Re: Proper way for deploying many applications sharing a common user database
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:> 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. >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Java
2007-Dec-28 14:53 UTC
Re: Proper way for deploying many applications sharing a common user database
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. On 28 Dez., 15:44, Sheryl Barrow <plotch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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: > > 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.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phillip Koebbe
2007-Dec-28 15:40 UTC
Re: Proper way for deploying many applications sharing a common user database
On Dec 28, 2007, at 7:50 AM, Ersin Er wrote:> > 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? >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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Robert Walker
2007-Dec-28 23:46 UTC
Re: Proper way for deploying many applications sharing a common user database
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. On Dec 28, 10:40 am, Phillip Koebbe <phillipkoe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Dec 28, 2007, at 7:50 AM, Ersin Er wrote: > > > > > 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? > > 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---