Note that there are some explanatory texts on larger screens.

plurals
  1. POInvalid argument to TimeZone?
    primarykey
    data
    text
    <p>I'm trying to make my users Time zone be the current Time zone of my application so everything they interact will be by it. I run into an <code>ArgumentError</code> for my method inside of my ApplicationController though.</p> <p><strong>application_controller.rb</strong></p> <pre><code>before_filter :set_user_time_zone private def set_user_time_zone if signed_in? Time.zone = Time.now.in_time_zone(current_user.time_zone) end end </code></pre> <p>Notes: current_user is a <a href="https://github.com/plataformatec/devise#controller-filters-and-helpers" rel="nofollow">Devise Helper</a> and my User model as a <code>:time_zone</code> column.</p> <p>Than the error:</p> <pre><code>invalid argument to TimeZone[]: Mon, 20 Aug 2012 13:16:20 JST +09:00 </code></pre> <p>I don't know where to go from here. Any ideas on how to correct this?</p> <p>Thanks.</p> <p><strong>UPDATE</strong></p> <pre><code>class Price attr_accessible :date def self.today where(:date =&gt; Date.today) end end </code></pre> <p>If my method does:</p> <pre><code>def set_user_time_zone if signed_in? Time.zone = current_user.time_zone end end </code></pre> <p>The problem I have my times are like this:</p> <pre><code> Time.now = US EAST- 2012-08-22 21:17:03 -0400 Time.zone = TOKYO - (GMT+09:00) Tokyo Time.zone.now 2012-08-23 10:17:03 +0900 </code></pre> <p>Which means all of my <code>Date</code> methods go by </p> <p><code>Time.now = US EAST- 2012-08-22 21:17:03 -0400</code></p> <p>when it should be</p> <pre><code>Time.zone.now 2012-08-23 10:17:03 +0900 </code></pre> <p>How can I get it to the latter?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload