Dynamic template system with RoR

There would be at least a couple of options, depending on how you want to implement the themes and how much they should differ from one another.

One would be to use the same views for the actions but have a different layout for each client. You could then use a method in your controller to select the appropriate layout:

class MyController < ApplicationController

layout :select_layout

def my_action

Perform action here



Say we have a field in our table defining the layout for the client

def select_layout

@client = Client.find() // whatever your query is

layout = @client.layout



See the documentation for the layout method at:


Alternatively you could look at a theming engine like liquid: http://home.leetsoft.com/liquid