Welcome Guest | Login

Sharing database?

Hi, although enjoying my conversion from PHP to RoR I have a generic question that I am unsure about.

Can I share a database between two different rails apps?

If not, has anyone any suggestions for this scenario:

I have various connected sites (the following site names are made up - I have no idea if they actually exist....)

prettyshoes.com
prettyhats.com
...
prettybelts.com

Each site has it's own rails app running it and has the usual db backend of items, prices, articles, blah, blah.

However, the 'pretty group' has a membership and community. If a visitor was visiting prettyshoes.com, they could register and opt in for the newsletter, etc. They could also opt in to receive the newsletter from prettyhats.com, prettybelts.com and so on.

In PHP I would simply connect the login area on each site to the same db. They share the same usernames, the same information, the same options, etc. A user could login on any of the 'pretty' sites and adjust their settings, details and so on.

In fact, it is pretty darned simple using my PHP knowledge and I would not give it a second thought of how to set it up, etc.

Now I am converting to RoR as I see the immense benefits, I am stuck as to how I would implement this very simple 'shared' db between the related sites.

Any thoughts appreciated and if that made no sense to anyone, let me know and I can try again :)

2007-02-23 05:23 AM

Nothing to see here. Move along now....
I'd venture to guess that they could all share the same database provided they can also use the same tables and other database-related variables. There is only one way to find out for sure though... make backups of your stuff and try it :)

Seth

2007-02-24 03:55 PM

Seth
Hi Seth,

I posted the same question on another forum and got the same answer. I feel a bit silly as the solution is pretty obvious really - I just never saw it that way!

Thanks for your time.

2007-02-24 05:23 PM

Nothing to see here. Move along now....
Useful - no worries... there's only one way to learn something you don't know :)

2007-02-24 05:26 PM

Seth
Yes, I did this with a user-account-and-profiles portion of a database that I needed to share between two related apps. Just copied the model files and tweaked them as needed. It worked just fine. However, in the end I ended up merging the two apps and am happier with the result... they fit together pretty well, and there's no duplication.

I would venture to say that in the case of prettyhats, prettybelts, etc.... wouldn't it make more sense to have one rails app run all of the sites? Because, I'm guessing most of the functionality is the same, the main difference is that the products offered need to be selected based on the domain name. So run everything of one application and db and have your template and database queries determined by the domain accessed. I've never done this so I have no idea whether it's easy to do or not, but just an idea...

2007-02-25 01:37 PM

Hi Bankerluke,

That was my next approach. As far as I am concerned, I may as well jump in the deep end and do it properly. I have been stuck in my 'old' ways for so long that I am sometimes finding it difficult to think differently.

now I don't think running all the sites from one app would be easy but would be the best solution by far. I'll keep on learning!

2007-02-25 04:04 PM

Nothing to see here. Move along now....

Hello Guest! In order to post you must be an active client with us, please log in or sign up today!