# Different views for different sites from same codebase?

**URL:** <https://www.ruby-forum.com/t/different-views-for-different-sites-from-same-codebase/104637>\
**Category:** Rails\
**Created:** [May 21, 2007, 2:14am UTC](https://www.ruby-forum.com/t/different-views-for-different-sites-from-same-codebase/104637 "2007-05-21T02:14:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmehta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea666f/32.png) [@rmehta](https://www.ruby-forum.com/u/rmehta)\
**Post date:** [May 21, 2007, 2:14am UTC](https://www.ruby-forum.com/t/different-views-for-different-sites-from-same-codebase/104637/1 "2007-05-21T02:14:48Z")

</div>

I need to develop an application which will have one codebase but  
different sites will be accessing the same codebase. Now the problem is  
that how can render different look and feel for the same view based on  
the site the request came from. For eg. if request came from [www.a.com](http://www.a.com)  
then all the screens will have the same functionality but differnt look  
then the request from [www.b.com](http://www.b.com). I can figure out the domain from where  
the request came, but don’t know how to setup the base for the view  
based on domain. Basically , I want one code base i.e. one set of  
controllers but n sets of views for each method if I am serving n sites.

Any help is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![rmehta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea666f/32.png) [@rmehta](https://www.ruby-forum.com/u/rmehta)\
**Post date:** [May 21, 2007, 2:30am UTC](https://www.ruby-forum.com/t/different-views-for-different-sites-from-same-codebase/104637/2 "2007-05-21T02:30:50Z")

</div>

Check out theme\_support from Matt McCray ([http://mattmccray.com/](http://mattmccray.com/)).  
He’s been MIA and you will need to patch it to work with Rails 1.2.

The plugin is basically extracted from Typo themes, so it has some  
limitations. Basically it lets you override any template from an  
application. So you can probably accomplish what you are looking for  
just by dropping in a new layout, and creating some wrapper code to  
select the theme based on the domain name. I am currently using it  
for a major product, and have submitted a couple patches to Matt but  
heard nothing back. I’m thinking about creating a derivative plugin  
called “multisite” or something that is specifically focused on what  
you’re asking.

---

<div class="post-metadata">

**Author:** ![rmehta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea666f/32.png) [@rmehta](https://www.ruby-forum.com/u/rmehta)\
**Post date:** [May 21, 2007, 2:37am UTC](https://www.ruby-forum.com/t/different-views-for-different-sites-from-same-codebase/104637/3 "2007-05-21T02:37:50Z")

</div>

There is the productize code as well.

Technically not compat. with Rails 1.0 but there is this:

[http://cwilliams.textdriven.com/articles/2006/02/10/productize-and-rails-1-0](http://cwilliams.textdriven.com/articles/2006/02/10/productize-and-rails-1-0)

that has working code for that.
