Make it even easier to set a new session store and use symbols for log level too

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2224 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson
2005-09-12 18:05:46 +00:00
parent 87e7ed8aef
commit 284570fd00
2 changed files with 18 additions and 6 deletions

View File

@@ -15,12 +15,12 @@ Rails::Initializer.run do |config|
# config.load_paths += %W( #{RAILS_ROOT}/app/services #{RAILS_ROOT}/app/services )
# Force all environments to use the same logger level
# (by default production uses INFO, the others DEBUG)
# config.log_level = Logger::DEBUG
# (by default production uses :info, the others :debug)
# config.log_level = :debug
# Use the database for sessions instead of the file system
# (create the session table with 'rake create_sessions_table')
# config.session_options[:database_manager] = CGI::Session::ActiveRecordStore
# config.session_store = :active_record_store
# Enable page/fragment caching by setting a file-based store
# (remember to create the caching directory and make it readable to the application)

View File

@@ -40,6 +40,7 @@ module Rails
initialize_framework_views
initialize_routing
initialize_session_settings
initialize_session_store
initialize_fragment_store
end
@@ -68,7 +69,7 @@ module Rails
begin
logger = Logger.new(configuration.log_path)
logger.level = configuration.log_level
logger.level = Logger.const_get(configuration.log_level.to_s.upcase)
rescue StandardError
logger = Logger.new(STDERR)
logger.level = Logger::WARN
@@ -101,6 +102,17 @@ module Rails
return unless configuration.frameworks.include?(:action_controller)
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.merge!(configuration.session_options)
end
def initialize_session_store
return if !configuration.frameworks.include?(:action_controller) || configuration.session_store.nil?
if configuration.session_store.is_a?(Symbol)
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:database_manager] =
CGI::Session.const_get(configuration.session_store.to_s.camelize)
else
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:database_manager] = configuration.session_store
end
end
def initialize_fragment_store
return if !configuration.frameworks.include?(:action_controller) || configuration.fragment_store.nil?
@@ -125,7 +137,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, :fragment_store
attr_accessor :session_options, :session_store, :fragment_store
def initialize
self.frameworks = default_frameworks
@@ -190,7 +202,7 @@ module Rails
end
def default_log_level
environment == 'production' ? Logger::INFO : Logger::DEBUG
environment == 'production' ? :info : :debug
end
def default_database_configuration_file