diff options
-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 |