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

Commit

Permalink
Implement user set time_zone
Browse files Browse the repository at this point in the history
  • Loading branch information
allenwq committed Oct 14, 2015
1 parent 8f22df8 commit 59c748c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class ApplicationController < ActionController::Base
helper_method :sort_direction, :sort_column
before_filter :init_gon
skip_before_filter :verify_authenticity_token
around_filter :set_time_zone, :if => :current_user

rescue_from CanCan::AccessDenied do |exception|
unless current_user
Expand Down Expand Up @@ -275,4 +276,8 @@ def not_found
helper_method :masquerading?
helper_method :curr_user_course
#helper_method :fb_liked?

def set_time_zone(&block)
Time.use_zone(current_user.try(:time_zone), &block)
end
end
1 change: 1 addition & 0 deletions app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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

<div class="control-group">
Expand Down

0 comments on commit 59c748c

Please sign in to comment.