Skip to content

Commit 779c29e

Browse files
committed
#14 add migration file. improve method set_time_zone.
# 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 #
1 parent 0b9f616 commit 779c29e

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ def #{s}!(redirect_url: nil)
6060

6161
private
6262
def set_time_zone
63-
Time.zone = current_user.time_zone if current_user and current_user.time_zone.present?
63+
Time.zone = current_user.time_zone if current_user&.time_zone&.present?
6464
end
6565
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddUserTimeZone < ActiveRecord::Migration[6.0]
2+
def change
3+
add_column :users, :time_zone, :string
4+
end
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddUserTimeZone < ActiveRecord::Migration[6.0]
2+
def change
3+
add_column :users, :time_zone, :string
4+
end
5+
end

0 commit comments

Comments
 (0)