From 6b284b87f224d8d4da074f98553ec9394f3d4c57 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 12 Dec 2004 12:43:48 +0000 Subject: Fixed CgiRequest so that it'll now accept session options with Symbols as keys (as the documentation points out) [Suggested by Andreas] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@117 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 8 ++++++++ actionpack/lib/action_controller/cgi_process.rb | 8 ++++++-- actionpack/lib/action_controller/cookies.rb | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index d31e2f15fe..b8a491f4d8 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,12 @@ *SVN* +* Fixed CgiRequest so that it'll now accept session options with Symbols as keys (as the documentation points out) [Suggested by Andreas] + +* Added that render_partial will always by default include a counter with value 1 unless there is a counter passed in via the + local_assigns hash that overrides it. As a result, render_collection_of_partials can still be written in terms of render_partial + and partials that make use of a counter can be called without problems from both render_collection_of_partials as well as + render_partial #295 [marcel] + * Fixed CgiRequest#out to fall back to #write if $stdout doesn't have #syswrite [bitsweat] * Fixed all helpers so that they use XHTML compliant double quotes for values instead of single quotes [htonl/bitsweat] @@ -120,6 +127,7 @@ * Fixed that link_to would escape & in the url again after url_for already had done so + *0.9.5* (28) * Added helper_method to designate that a given private or protected method you should available as a helper in the view. [bitsweat] diff --git a/actionpack/lib/action_controller/cgi_process.rb b/actionpack/lib/action_controller/cgi_process.rb index 148cb81df0..64bfc1ed07 100644 --- a/actionpack/lib/action_controller/cgi_process.rb +++ b/actionpack/lib/action_controller/cgi_process.rb @@ -36,7 +36,7 @@ module ActionController #:nodoc: attr_accessor :cgi DEFAULT_SESSION_OPTIONS = - { "database_manager" => CGI::Session::PStore, "prefix" => "ruby_sess.", "session_path" => "/" } + { :database_manager => CGI::Session::PStore, :prefix => "ruby_sess.", :session_path => "/" } def initialize(cgi, session_options = {}) @cgi = cgi @@ -67,7 +67,7 @@ module ActionController #:nodoc: def session return @session unless @session.nil? begin - @session = (@session_options == false ? {} : CGI::Session.new(@cgi, DEFAULT_SESSION_OPTIONS.merge(@session_options))) + @session = (@session_options == false ? {} : CGI::Session.new(@cgi, session_options_with_string_keys)) @session["__valid_session"] return @session rescue ArgumentError => e @@ -94,6 +94,10 @@ module ActionController #:nodoc: def new_session CGI::Session.new(@cgi, DEFAULT_SESSION_OPTIONS.merge(@session_options).merge("new_session" => true)) end + + def session_options_with_string_keys + DEFAULT_SESSION_OPTIONS.merge(@session_options).inject({}) { |options, pair| options[pair.first.to_s] = pair.last; options } + end end class CgiResponse < AbstractResponse #:nodoc: diff --git a/actionpack/lib/action_controller/cookies.rb b/actionpack/lib/action_controller/cookies.rb index 1eb071bdbe..6b9954f84d 100644 --- a/actionpack/lib/action_controller/cookies.rb +++ b/actionpack/lib/action_controller/cookies.rb @@ -41,7 +41,7 @@ module ActionController #:nodoc: def []=(name, options) if options.is_a?(Hash) - options.each { |key, value| options[key.to_s] = value } + options = options.inject({}) { |options, pair| options[pair.first.to_s] = pair.last; options } options["name"] = name.to_s else options = { "name" => name, "value" => options } -- cgit v1.2.3