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

Allow symbols to be used as names for setting cookies

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@22 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2004-11-26 02:11:42 +00:00
parent defda16b83
commit 177cae5483
2 changed files with 3 additions and 3 deletions

View file

@ -36,13 +36,13 @@ module ActionController #:nodoc:
# Returns the value of the cookie by +name+ -- or nil if no such cookie exist. You set new cookies using either the cookie method
# or cookies[]= (for simple name/value cookies without options).
def [](name)
@cookies[name].value if @cookies[name]
@cookies[name.to_s].value if @cookies[name.to_s]
end
def []=(name, options)
if options.is_a?(Hash)
options.each { |key, value| options[key.to_s] = value }
options["name"] = name
options["name"] = name.to_s
else
options = [ name, options ]
end

View file

@ -18,7 +18,7 @@ class CookieTest < Test::Unit::TestCase
end
def authenticate_for_fourten_days_with_symbols
cookies["user_name"] = { :value => "david", :expires => Time.local(2005, 10, 10) }
cookies[:user_name] = { :value => "david", :expires => Time.local(2005, 10, 10) }
render_text "hello world"
end