|
|
Overview
With this plugin, you can generate different sets of views in a subdirectory named "sites". Each subdirectory of "sites" can be added to the view_paths array with a simple declaration. The specifics of choosing a site are left to the developer, but once chosen, the specified site directory will be referenced first when template searches occur. The result is the ability to selectively override the main application templates.
Installation
Standard way:
script/plugin source http://rails-multisite.googlecode.com/svn/trunk script/plugin install multisite
Without bloating your plugin source list:
script/plugin install http://rails-multisite.googlecode.com/svn/trunk/multisite
Via piston:
piston import http://rails-multisite.googlecode.com/svn/trunk/multisite vendor/plugins/multisite
The last two methods can also pull a specific version (if necessary) from:
http://rails-multisite.googlecode.com/svn/tags/
Usage
The original use case was for an app hosted at multiple domains to be customized on each domain. However domain semantics aren't tied into this plugin because it's too specific, and assuming a one-to-one mapping between domains and sites would have been heavy-handed. The site can be declared statically as:
site 'mine'
or as a method that will run dynamically for each request:
site :determine_site
private
def determine_site
request.host.split('.')[-2]
endThe lineage of this plugin is Matt McCray's theme_support, however that plugin has a slightly different use case, and is currently designed for Rails 1.1 and 1.2 with a couple 3rd party patches. Multisite has a much simpler focus and requires Rails 2.0 due to the multiple controller view paths functionality which makes the whole thing like butta.
