This project is archived and is in readonly mode.
[PATCH] Memoize cookies so they can be retrieved in the same response / request cycle
Reported by Olly | May 28th, 2009 @ 01:40 PM | in 2.3.4
If you set a cookie in a controller action and then try and access the new value in later in the action or in the view, the old value for the cookie is retrieved because the CookieJar is re-initialized with each call to ActionController::Base#cookies.
# Contrived example
# Before patch:
def show
cookies[:logged_in] = true
cookies[:logged_in] # => nil
end
# After patch:
def show
cookies[:logged_in] = true
cookies[:logged_in] # => true
end
Related thread on Core mailing list.
Comments and changes to this ticket
-
josh May 28th, 2009 @ 03:10 PM
- Milestone cleared.
- State changed from new to open
- Assigned user set to josh
-
Repository May 28th, 2009 @ 03:35 PM
- State changed from open to resolved
(from [0349278f3da9f7f532330cf295eed35ede3bae66]) Memoize cookies so that updates to cookies are available in the current request. [#2733 state:resolved]
Signed-off-by: Joshua Peek josh@joshpeek.com
http://github.com/rails/rails/commit/0349278f3da9f7f532330cf295eed3... -
Repository July 21st, 2009 @ 10:47 PM
(from [143c55d325388aa2384de8f137cfb61c09912208]) Memoize cookies so that updates to cookies are available in the current request. [#2733 state:resolved]
Signed-off-by: Joshua Peek josh@joshpeek.com
Conflicts:
actionpack/test/controller/cookie_test.rb
http://github.com/rails/rails/commit/143c55d325388aa2384de8f137cfb6...
-
Bryan Helmkamp August 10th, 2009 @ 11:49 PM
This change introduced a regression which is captured here: https://rails.lighthouseapp.com/projects/8994/tickets/3032-regressi...
-
Jeremy Kemper August 10th, 2009 @ 11:50 PM
- State changed from resolved to open
- Milestone set to 2.3.4
Bryan ran into a regression with this.
-
John Pignata August 25th, 2009 @ 04:57 AM
Bryan -- I'm not sure that this actually did introduce a regression. Your test seems to work when I call cookies.clear against the controller which is how the other tests interact with it
def test_cookies_are_clearable_from_test get :authenticate @controller.send(:cookies).clear response = get :count assert_equal "0", response.body end
-
josh August 31st, 2009 @ 07:45 PM
- State changed from open to resolved
Reresolving.
We should update the functional test cookie accessor to behave more like the integration one.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 3032 Regression on 2.3 branch: Can't delete cookies from inside a test #2733
- 3032 Regression on 2.3 branch: Can't delete cookies from inside a test See my question in #2733.
- 2733 [PATCH] Memoize cookies so they can be retrieved in the same response / request cycle (from [0349278f3da9f7f532330cf295eed35ede3bae66]) Memoize...
- 2930 Fix for not being able to read a cookie set mid-request This was a dupe of #2733 and I've cherry-picked that patc...
- 2733 [PATCH] Memoize cookies so they can be retrieved in the same response / request cycle (from [143c55d325388aa2384de8f137cfb61c09912208]) Memoize...