diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-12 18:05:46 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-12 18:05:46 +0000 |
commit | 284570fd00cc2a61dd93b35d270b1d8386618185 (patch) | |
tree | 18d683f3576716b1727623d460add4f521c207a9 /railties | |
parent | 87e7ed8aef159674447b75b83746ba0e7d2e44e3 (diff) | |
download | rails-284570fd00cc2a61dd93b35d270b1d8386618185.tar.gz rails-284570fd00cc2a61dd93b35d270b1d8386618185.tar.bz2 rails-284570fd00cc2a61dd93b35d270b1d8386618185.zip |
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
Diffstat (limited to 'railties')
-rw-r--r-- | railties/environments/environment.rb | 6 | ||||
-rw-r--r-- | railties/lib/initializer.rb | 18 |
2 files changed, 18 insertions, 6 deletions
diff --git a/railties/environments/environment.rb b/railties/environments/environment.rb index b6fd5e5f73..ea381a158a 100644 --- a/railties/environments/environment.rb +++ b/railties/environments/environment.rb @@ -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) diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 8e17af105a..83857df230 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_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 |