Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Fix for code sample in Time.zone= comment

#6370

Hi,

This is just a small update to the docs for Time.zone=.

Even though Time.zone is thread-local, it will leak across requests within the same thread if you handle one request with a logged-in user and the next request with a logged-out user.

This little change updates the sample code to use an around_filter instead of a before_filter to show how to fix this.

P.S. You might be tempted to combine the first two lines of set_time_zone into one line with the comma assignment syntax and add "if logged_in? to the one line in the ensure clause. Don't do it. If you did that, the user's time zone would leak out to the next request when the user logs out.

Reported by Brian Morearty · February 4th, 2011 @ 04:46 AM

State: resolved
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Brian Morearty
    Brian Morearty
    • Tag changed from documentation, timezone to doc, documentation, timezone

    February 4th, 2011 @ 04:48 AM

  2. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to resolved
    • Importance changed from to Low

    Hey Brian do you mind to go ahead and just push your changes to http://github.com/lifo/docrails this repo has free access to push and is the official way for docs :).

    February 4th, 2011 @ 01:31 PM

  3. Brian Morearty
    Brian Morearty

    Thanks, Santiago. I missed the little note about how to push doc changes at the end of the contributor guide.

    I've made the doc patch in docrails.

    February 4th, 2011 @ 05:20 PM

  4. Santiago Pastorino
  5. bingbing