Skip to content

Commit

Permalink
jasl#14 add migration file. improve method set_time_zone.
Browse files Browse the repository at this point in the history
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date:      Wed Aug 14 17:45:34 2019 +0800
#
# On branch user-time-zone
# Your branch is up to date with 'origin/user-time-zone'.
#
# Changes to be committed:
#	modified:   app/controllers/application_controller.rb
#	new file:   db/migrate/20190809022738_add_user_time_zone.rb
#	new file:   db/migrate/20190814094307_add_user_time_zone.rb
#
# Changes not staged for commit:
#	deleted:    db/migrate/20190814094307_add_user_time_zone.rb
#
# Untracked files:
#	.generators
#	.idea/
#	.rakeTasks
#
  • Loading branch information
Xu-Zhiqing committed Aug 14, 2019
1 parent 0b9f616 commit 779c29e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def #{s}!(redirect_url: nil)

private
def set_time_zone
Time.zone = current_user.time_zone if current_user and current_user.time_zone.present?
Time.zone = current_user.time_zone if current_user&.time_zone&.present?
end
end
5 changes: 5 additions & 0 deletions db/migrate/20190809022738_add_user_time_zone.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddUserTimeZone < ActiveRecord::Migration[6.0]
def change
add_column :users, :time_zone, :string
end
end
5 changes: 5 additions & 0 deletions db/migrate/20190814094307_add_user_time_zone.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddUserTimeZone < ActiveRecord::Migration[6.0]
def change
add_column :users, :time_zone, :string
end
end

0 comments on commit 779c29e

Please sign in to comment.