mirror of https://github.com/rails/rails
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:
parent
defda16b83
commit
177cae5483
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue