class Time
def zone=(time_zone)
end
end
yield
else
Time.use_zone(current_user.time_zone) { yield }
if logged_in?
def set_time_zone
around_action :set_time_zone
class ApplicationController < ActionController::Base
current_user.time_zone just needs to return a string identifying the user's preferred time zone:
Here's an example of how you might set Time.zone on a per request basis and reset it when the request is done.
* An identifier for a TZInfo::Timezone object (e.g., "America/New_York").
* A TZInfo::Timezone object.
* An identifier for a Rails TimeZone object (e.g., "Eastern Time (US & Canada)", -5.hours).
* A Rails TimeZone object.
This method accepts any of the following:
Sets Time.zone to a TimeZone object for the current request/thread.
def zone=(time_zone) ::ActiveSupport::IsolatedExecutionState[:time_zone] = find_zone!(time_zone) end