1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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
This commit is contained in:
David Heinemeier Hansson 2004-12-12 12:43:48 +00:00
parent 9ee94ab13a
commit 6b284b87f2
3 changed files with 15 additions and 3 deletions

View file

@ -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]

View file

@ -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:

View file

@ -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 }