Created
June 25, 2019 00:56
-
-
Save rakibulislam/a987734329df8238cd2db4e77299dfd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Here's an example of how you might set <tt>Time.zone</tt> on a per request basis and reset it when the request is done. | |
# <tt>current_user.time_zone</tt> just needs to return a string identifying the user's preferred time zone: | |
# | |
class ApplicationController < ActionController::Base | |
around_action :set_time_zone | |
def set_time_zone | |
if logged_in? | |
Time.use_zone(current_user.time_zone) { yield } | |
else | |
yield | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment