Permalink
Browse files

Make it even easier to set a new session store and use symbols for lo…

…g level too

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2224 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 87e7ed8 commit 284570fd00cc2a61dd93b35d270b1d8386618185 @dhh dhh committed Sep 12, 2005
Showing with 18 additions and 6 deletions.
  1. +3 −3 railties/environments/environment.rb
  2. +15 −3 railties/lib/initializer.rb
@@ -15,12 +15,12 @@
# 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)
@@ -40,6 +40,7 @@ def process
initialize_framework_views
initialize_routing
initialize_session_settings
+ initialize_session_store
initialize_fragment_store
end
@@ -68,7 +69,7 @@ def initialize_logger
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 @@ def initialize_session_settings
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 @@ def initialize_fragment_store
# 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 @@ def default_log_path
end
def default_log_level
- environment == 'production' ? Logger::INFO : Logger::DEBUG
+ environment == 'production' ? :info : :debug
end
def default_database_configuration_file

0 comments on commit 284570f

Please sign in to comment.