Set an ActionController's template root on each request for a
domain acts as account key pattern. Careful with this code though. It relies on the behavior of a private rails method and could change 50 times in the next week. (
see my blog post)
class MyController < ActionController::Base
before_filter :set_site_template_root
def set_site_template_root
self.class.template_root = "#{RAILS_ROOT}/#{app}/#{views}/#{current_site.domain}")
@template.base_path = template_root
end
endmodule ActionView
class Base
private
alias_method :rails_assign_method_name, :assign_method_name
def assign_method_name(extension, template, file_name)
rails_method_name = rails_assign_method_name(extension, template, file_name)
@@method_names[file_name || template] = respond_to?(:current_site) ?
"#{rails_method_name}_#{current_site.domain}".intern :
rails_method_name
end
end
end