# Tips for providing multiple layouts in a multisite environment (aka the SaaS holy grail)

**URL:** <https://www.ruby-forum.com/t/tips-for-providing-multiple-layouts-in-a-multisite-environment-aka-the-saas-holy-grail/142590>\
**Category:** Rails\
**Created:** [July 9, 2008, 2:28pm UTC](https://www.ruby-forum.com/t/tips-for-providing-multiple-layouts-in-a-multisite-environment-aka-the-saas-holy-grail/142590 "2008-07-09T14:28:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlangenberg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@mlangenberg](https://www.ruby-forum.com/u/mlangenberg)\
**Post date:** [July 9, 2008, 2:28pm UTC](https://www.ruby-forum.com/t/tips-for-providing-multiple-layouts-in-a-multisite-environment-aka-the-saas-holy-grail/142590/1 "2008-07-09T14:28:28Z")

</div>

One of the apps I’m working on is a SaaS solution for an online  
product catalog. Every catalog has it’s own domain and can be accessed  
as if it’s a site on its own (www.client\_a.com and www.client\_b.com  
are both served by the same Rails app).

Now building this app all works well, but I’m having some troubles  
thinking of a good solution for the templating system. Since these  
online catalogs are extending already existing websites of our clients  
it is needless to say that the templating system should be highly  
customizable.

There are a few solutions I have tried (and a few I’ve not), I’ll  
share those with you and I’m interested with your solutions to this  
kind of problem.

1. Use the same erb templates for all catalogs, returning the same  
HTML structure for every catalog, but using a custom stylesheet per  
catalog. So turning the stylesheet plus images into metadata.  
Pro: easy to implement.  
Con: CSS is very limited to customize a layout.  
Con: The designer guy now hates me.  
Con: The CSS/images aren’t in the same git repository, and you need to  
use something like FTP to update them.

2. Also turn everything under app/views into metadata.  
Pro: The sky is the limit  
Con: Hard to implement.  
Con: Hard to maintain.  
Con: You don’t have custom controllers/actions (or models) for  
seperate pages and logic.  
Con: You quickly resort to ugly hacks because of the above reasons  
Con: Do I also need custom helpers per catelog? Are helpers metadata?  
Con: Templates are edited on a remote machine.

3. Use a different partial per html snippet per catalog.  
(haven’t tried this yet)

4. Some kind of templating engine?

Any other ideas?

Recognizing the subdomain and doing the routing is really the easiest  
thing of a SaaS solution. But when you want to provide ‘homepages’ to  
clients through a SaaS solution, it’s a lot tougher!
