Skip to content
This repository was archived by the owner on Sep 25, 2019. It is now read-only.

Commit 859c9cd

Browse files
committed
Implement user set time_zone
1 parent 8f22df8 commit 859c9cd

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

app/controllers/application_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class ApplicationController < ActionController::Base
44
helper_method :sort_direction, :sort_column
55
before_filter :init_gon
66
skip_before_filter :verify_authenticity_token
7+
around_filter :set_time_zone, if: :current_user
78

89
rescue_from CanCan::AccessDenied do |exception|
910
unless current_user
@@ -275,4 +276,8 @@ def not_found
275276
helper_method :masquerading?
276277
helper_method :curr_user_course
277278
#helper_method :fb_liked?
279+
280+
def set_time_zone(&block)
281+
Time.use_zone(current_user.try(:time_zone), &block)
282+
end
278283
end

app/views/users/edit.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
<%= simple_form_for current_user, url: users_update_path, html: {class: "form-horizontal"} do |f| %>
1919
<%= f.input :name %>
20+
<%= f.input :time_zone %>
2021
<%= f.input :use_uploaded_picture, as: :boolean %>
2122

2223
<div class="control-group">

0 commit comments

Comments
 (0)