Permalink
Browse files

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
  • Loading branch information...
1 parent defda16 commit 177cae5483736e20bc8b1f878a4f1a52eed26a10 @dhh dhh committed Nov 26, 2004
Showing with 3 additions and 3 deletions.
  1. +2 −2 actionpack/lib/action_controller/cookies.rb
  2. +1 −1 actionpack/test/controller/cookie_test.rb
@@ -36,13 +36,13 @@ def initialize(controller)
# 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 @@ def authenticate_for_fourten_days
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

0 comments on commit 177cae5

Please sign in to comment.