title: Setting Time.zone during a request: Thread Safe?
body: <p>I'd like to let users of my app specify a time zone, and then set their time zone at the beginning of each request.  In Rails, AFAICT, this is done by setting the singleton object:</p>
  
  <pre><code>Time.zone = "America/Los_Angeles"
  </code></pre>
  
  <p>My understanding of best practices is that, generally speaking, a singleton should be set ONCE.  For example in the application configuration.</p>
  
  <p>From an answer to a similar question, someone suggests setting it in the ApplicationController</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    before_filter :set_timezone
    def set_timezone
      # current_user.time_zone #=&gt; 'London'
      Time.zone = current_user.time_zone if current_user &amp;&amp; current_user.time_zone
    end
  end
  </code></pre>
  
  <p>Is this safe?  Or do I run a risk of having one thread affect another?  I will try running a test of this but it's not the easiest test scenario ever so I thought I should see if someone has already done this.</p>