Skip to content

Commit 0670b68

Browse files
author
gabriel.d
committed
Fix for Rails 2.0.2. No monkey patch required now!
git-svn-id: https://rails-multisite.googlecode.com/svn/trunk@8 64db17d9-5632-0410-b012-75deaefb9678
1 parent f56080f commit 0670b68

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

README

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
This plugin provides basic support for hosting multiple sites on the same Rails code base. It is based on Matt McCray's theme_support plugin, but is essentially completely gutted and rewritten with a different focus.
44

5-
The essential functionality of the plugin is to add a specific site's views to the view path. The concept of a view_path is new to Rails 2.0, so you will need to be running edge to use this plugin for right now.
5+
The essential functionality of the plugin is to add a specific site's views to the view path. The concept of a view_path is new to Rails 2.0.
6+
7+
== Requirements
8+
9+
* This plugin is tested in Rails 2.0.2.
10+
* Template caching must be disabled (this includes both cache_template_loading and cache_template_extensions action_view config options)
611

712
== Differences from theme_support
813

@@ -57,5 +62,5 @@ the site for the whole application.
5762

5863

5964
---
60-
Copyright (c) 2007 Gabe da Silveira, based on code from theme_support by Matt McCray, based on code from Typo by Tobias Luetke
65+
Copyright (c) 2007-2008 Gabe da Silveira, based on code from theme_support by Matt McCray, based on code from Typo by Tobias Luetke
6166
released under the MIT license

init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Initializes multisite support by adding a macro to ActionController::Base
2-
require 'patches/actioncontroller_ex'
2+
require 'patches/actioncontroller_ex'

lib/patches/actioncontroller_ex.rb

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# end
1818
def self.site(site_name)
1919
write_inheritable_attribute "site", site_name
20-
around_filter :temporarily_add_multisite_path
20+
before_filter :add_multisite_path
2121
end
2222

2323
# Retrieves the current set site
@@ -32,17 +32,14 @@ def current_site(passed_site=nil)
3232
end
3333

3434
protected
35-
def temporarily_add_multisite_path
35+
def add_multisite_path
3636
if current_site
37-
begin
38-
ActionController::Base.view_paths.unshift(File.join(RAILS_ROOT,'sites', @active_site, 'views'))
39-
logger.info "paths: " + ActionController::Base.view_paths.join(":")
40-
yield
41-
ensure
42-
ActionController::Base.view_paths.shift
43-
end
44-
else
45-
yield
37+
raise "Multisite plugin is incompatible with template caching. You must set config.action_view.cache_template_loading to false in your environment." if ActionView::Base.cache_template_loading
38+
raise "Multisite plugin is incompatible with template extension caching. You must set config.action_view.cache_template_extensions to false in your environment." if ActionView::Base.cache_template_extensions
39+
new_path = File.join(RAILS_ROOT, 'sites', @active_site, 'views')
40+
@template.prepend_view_path(new_path)
41+
logger.info " Template View Paths: #{@template.view_paths.inspect}"
4642
end
43+
return true
4744
end
4845
end

0 commit comments

Comments
 (0)