What is the best way to implement skinning in a Rails app

445 Views Asked by At

Using Rails, I am building several sites which are very similar. I want to implement these as one Rails app answering to multiple domains, and change what is presented and the processing logic based on the domain name. The areas I need to change/skin per site are:

  • Views: The fields on a page differ slightly by site. Some sites have more/different fields than others, but there are some that are common across all
  • Models (which seems best to do this by defining a super class for the main model which varies and implement a subcalss for each site)
  • Controller logic. There is a lot of similarity but a few small processing differences, including which Model subclass to deal with
  • CSS (which seems fairly straight forward)

I have already implemented a mechanism which makes the current domain/app name visible to the views, controllers and models.

I was thinking of defining a view partial per site and using ERB logic to include the right one. The controllers seem like the least obvious part.

Any suggestions very much appreciated.

Cheers Paul

1

There are 1 best solutions below

0
On

I have implemented something similar for our application, HiringThing (http://www.hiringthing.com)

To do so, we use a before_filter on the application controller that parses request.host and determines what website the request is for. That then sets a variable @site that we reference in views, controllers and models to determine versioning requirements at runtime.