# Multiple sites sharing a single application

**URL:** <https://www.ruby-forum.com/t/multiple-sites-sharing-a-single-application/58529>\
**Category:** Rails\
**Created:** [April 22, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/multiple-sites-sharing-a-single-application/58529 "2006-04-22T19:35:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [April 22, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/multiple-sites-sharing-a-single-application/58529/1 "2006-04-22T19:35:46Z")

</div>

Quick question:

Say i have a few shopping sites that i want to run on the same  
application code but have seperate databases and layout/design, what  
would be the neatest ‘Rails’ way of doing this?

Cheers,

Steve

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [April 22, 2006, 7:42pm UTC](https://www.ruby-forum.com/t/multiple-sites-sharing-a-single-application/58529/2 "2006-04-22T19:42:01Z")

</div>

Stephen B. wrote:

> Quick question:
> 
> Say i have a few shopping sites that i want to run on the same  
> application code but have seperate databases and layout/design, what  
> would be the neatest ‘Rails’ way of doing this?

The _Rails_ way would be to not have different databases… but access  
specific data within scope. The reason behind this is that its much  
easier to maintain one database schema than multiple ones and trying to  
keep those in sync with each other… especially if one instance of the  
application is doing all the heavy lifting.

-Robby

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [April 23, 2006, 3:24am UTC](https://www.ruby-forum.com/t/multiple-sites-sharing-a-single-application/58529/3 "2006-04-23T03:24:08Z")

</div>

Stephen B. wrote:

> Quick question:
> 
> Say i have a few shopping sites that i want to run on the same  
> application code but have seperate databases and layout/design, what  
> would be the neatest ‘Rails’ way of doing this?
> 
> Cheers,
> 
> Steve

Sounds a little like a job for SVN branches. You could keep your models  
in the trunk and branch the controllers and views, or at least just the  
views. This would be a quick and dirty way to implement a quick “themes”  
system for your application.

As far as running entirely separate instances of the application, I  
would suggest using several databases. If they’re not truly the “same”  
application, then keeping all that data together and adding some sort of  
scope is just going to complicate things. Other than their base  
software, these different sites are really separate, so make it easy on  
yourself and deploy it that way.

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [April 23, 2006, 12:13pm UTC](https://www.ruby-forum.com/t/multiple-sites-sharing-a-single-application/58529/4 "2006-04-23T12:13:23Z")

</div>

I think that makes more sense. This would allow for the sites to  
‘split’ from the common application if one site needed to add additional  
bespoke componants. The main reason for maintaining the core codebase  
was for code management - i just wouldn’t want to have to bug fix across  
3 different places.

Cheers,

Steve

---

<div class="post-metadata">

**Author:** ![stepheneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/71e660/32.png) [@stepheneb](https://www.ruby-forum.com/u/stepheneb)\
**Post date:** [April 23, 2006, 9:08pm UTC](https://www.ruby-forum.com/t/multiple-sites-sharing-a-single-application/58529/5 "2006-04-23T21:08:45Z")

</div>

Bryan D. wrote:

> Stephen B. wrote:
> 
> > Quick question:
> > 
> > Say i have a few shopping sites that i want to run on the same  
> > application code but have seperate databases and layout/design, what  
> > would be the neatest ‘Rails’ way of doing this?
> > 
> > Cheers,
> > 
> > Steve
> 
> Sounds a little like a job for SVN branches. You could keep your models  
> in the trunk and branch the controllers and views, or at least just the  
> views. This would be a quick and dirty way to implement a quick “themes”  
> system for your application.

There is also the svn:externals  
([Externals Definitions](http://svnbook.red-bean.com/en/1.0/ch07s03.html)) solution :  
A. create an application framework without the modified parts (probably  
CSS, config and views)  
B. checkout this app for each site  
C. set an svn:external on each of these directories to point to the code  
for each specific site. Example:

# svn propset svn:externals ‘app/views’ “svn://example.com/site1/views”

“views”  
D. svn up will update code in both app and site specific code. svn  
status will tell you to do svn ci into ‘views’ if needed.
