diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-11-26 01:12:46 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-11-26 01:12:46 +0000 |
commit | b62937acbd5c14d6499f4e45f4b821043a826044 (patch) | |
tree | 5c68ac26b66a29dbf18c62b11a97f7aec5499f47 /actionpack | |
parent | bd5985331c701f501bdef859204f6fabc279e87a (diff) | |
download | rails-b62937acbd5c14d6499f4e45f4b821043a826044.tar.gz rails-b62937acbd5c14d6499f4e45f4b821043a826044.tar.bz2 rails-b62937acbd5c14d6499f4e45f4b821043a826044.zip |
Added ActionController#cookies[]= as an alias for cookie "name", "value" -- youll still need to use the latter if you have options to set.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@19 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rwxr-xr-x | actionpack/lib/action_controller/base.rb | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index ead5e189ff..87280683fc 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added ActionController#cookies[]= as an alias for cookie "name", "value" -- you'll still need to use the latter if you have options to set. + * Added ActionController#cookies[] as a reader for @cookies that'll return the value of the cookie instead of the cookie object itself. NOTE: If you were using the old accessor, this could potentially break your code -- if you expect a full cookie object! diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 74fd0fbab9..5c386ac05a 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -555,11 +555,17 @@ module ActionController #:nodoc: @response.headers["cookie"] << CGI::Cookie.new(*options) end - # Returns the value of the cookie by +name+ -- or nil if no such cookie exist. You set new cookies using the cookie method. + # Alias for cookie "name", "value" + def cookies[]=(name, value) + cookie(name, value) + end + + # 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 cookies[](name) @cookies[name].value if @cookies[name] end - + # Resets the session by clearsing out all the objects stored within and initializing a new session object. def reset_session #:doc: @request.reset_session |