changing your ActionController template_root per request

Normally, you change your template root with a class variable:

class MyController < ActionController::Base
  self.template_root = File.join(RAILS_ENV, 'app', 'views')
end

The publishing framework can use different view paths depending on which domain is being accessed. So without thinking, I try:

class MyController < ActionController::Base
  before_filter { |c| c.template_root = my_new_template_root }
end

The problem, however, is the the controller sets up the intial ActionView classes before calling the filters.

class MyController < ActionController::Base
  before_filter :set_site_template_root
  def set_site_template_root
    self.class.template_root = File.join(RAILS_ROOT, 'app', 'views', current_site.domain)
    @template.base_path = template_root
  end
end

All good, except the layout doesn't show up...