aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-09-12 17:49:07 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-09-12 17:49:07 +0000
commit87e7ed8aef159674447b75b83746ba0e7d2e44e3 (patch)
tree55fa488b1e73bd258bdbaa08a54433c75a50ee72 /railties
parent691f95e448bca0123eb3c22e4f280d56f33db84d (diff)
downloadrails-87e7ed8aef159674447b75b83746ba0e7d2e44e3.tar.gz
rails-87e7ed8aef159674447b75b83746ba0e7d2e44e3.tar.bz2
rails-87e7ed8aef159674447b75b83746ba0e7d2e44e3.zip
Added Rails::Configuration support for fragment stores
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2223 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r--railties/environments/environment.rb4
-rw-r--r--railties/lib/initializer.rb18
2 files changed, 20 insertions, 2 deletions
diff --git a/railties/environments/environment.rb b/railties/environments/environment.rb
index 98518031fa..b6fd5e5f73 100644
--- a/railties/environments/environment.rb
+++ b/railties/environments/environment.rb
@@ -22,6 +22,10 @@ Rails::Initializer.run do |config|
# (create the session table with 'rake create_sessions_table')
# config.session_options[:database_manager] = CGI::Session::ActiveRecordStore
+ # Enable page/fragment caching by setting a file-based store
+ # (remember to create the caching directory and make it readable to the application)
+ # config.fragment_store = :file_store, "#{RAILS_ROOT}/cache"
+
# See Rails::Configuration for more options
end
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index c714b3b621..8e17af105a 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -40,6 +40,7 @@ module Rails
initialize_framework_views
initialize_routing
initialize_session_settings
+ initialize_fragment_store
end
def set_load_path
@@ -97,9 +98,22 @@ module Rails
end
def initialize_session_settings
- return if !configuration.frameworks.include?(:action_controller)
+ return unless configuration.frameworks.include?(:action_controller)
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.merge!(configuration.session_options)
end
+
+ def initialize_fragment_store
+ return if !configuration.frameworks.include?(:action_controller) || configuration.fragment_store.nil?
+
+ configuration.fragment_store = [ configuration.fragment_store ].flatten
+ store = ActionController::Caching::Fragments.const_get(configuration.fragment_store.first.to_s.camelize)
+
+ if parameters = configuration.fragment_store[1..-1]
+ ActionController::Base.fragment_cache_store = store.new(*parameters)
+ else
+ ActionController::Base.fragment_cache_store = store.new
+ end
+ end
end
# The Configuration class holds all the parameters for the Initializer and ships with defaults that suites most
@@ -111,7 +125,7 @@ module Rails
# Rails::Initializer.run(:process, config)
class Configuration
attr_accessor :frameworks, :load_paths, :log_level, :log_path, :database_configuration_file, :view_path, :controller_paths
- attr_accessor :session_options
+ attr_accessor :session_options, :fragment_store
def initialize
self.frameworks = default_frameworks