subject = Subject.new(name:"First Subject", position: 1, visible: true)
irb(main):008:0* subject.save
(0.2ms) BEGIN
SQL (2.8ms) INSERT INTO `subjects` (`name`, `position`, `visible`, `created_at`, `updated_at`) VALUES ('First Subject', 1, 1, '2016-04-16 01:52:31', '2016-04-16 01:52:31')
(1.5ms) COMMIT
irb(main):008:0* subject
=> #<Subject id: 1, name: "First Subject", position: 1, visible: true, created_at: "2016-04-16 01:52:31", updated_at: "2016-04-16 01:52:31">
本來是在10點左右保存的,但是裡面的created_at, updated_at時間是1點,不和系統時間一致。
ringa_lee2017-04-24 09:15:29
config/application.rb
config.active_record.default_timezone = :local
目前還不太明白,參考 https://ruby-china.org/topics/16187
ringa_lee2017-04-24 09:15:29
時區是哪個時區 是東八區麼? 加上8小時看看是幾點
irb>Time.now
=> 2016-05-12 15:30:14 +0800
是這樣的嗎