diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-11-26 01:09:59 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-11-26 01:09:59 +0000 |
commit | bd5985331c701f501bdef859204f6fabc279e87a (patch) | |
tree | 658dd064e4fc912d1c2dc81adeec50b4a7bb7066 /actionpack | |
parent | e15b371777b72b6f2e71f27c5d55768083c87996 (diff) | |
download | rails-bd5985331c701f501bdef859204f6fabc279e87a.tar.gz rails-bd5985331c701f501bdef859204f6fabc279e87a.tar.bz2 rails-bd5985331c701f501bdef859204f6fabc279e87a.zip |
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!
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@18 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 3 | ||||
-rwxr-xr-x | actionpack/lib/action_controller/base.rb | 9 |
2 files changed, 8 insertions, 4 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 77cb4ee6f1..ead5e189ff 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,8 @@ *SVN* +* 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! + * Added the opportunity to defined method_missing on a controller which will handle all requests for actions not otherwise defined #223 [timb] * Fixed AbstractRequest#remote_ip for users going through proxies - Patch #228 [Eric Hodel] diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 4816ef7f71..74fd0fbab9 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -235,10 +235,6 @@ module ActionController #:nodoc: # directive. Values should always be specified as strings. attr_accessor :headers - # Holds a hash of cookie names and values. Accessed like <tt>@cookies["user_name"]</tt> to get the value of the user_name cookie. - # This hash is read-only. You set new cookies using the cookie method. - attr_accessor :cookies - # Holds the hash of variables that are passed on to the template class to be made available to the view. This hash # is generated by taking a snapshot of all the instance variables in the current scope just before a template is rendered. attr_accessor :assigns @@ -559,6 +555,11 @@ 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. + 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 |