在控制台上创建表记录时,时间显示不正确
2.0.0p247 :022 > user.updated_at
 => Fri, 26 Jul 2013 14:17:27 UTC +00:00
然而我系统的时间是正确的
$ date
Fri Jul 26 22:18:54 CST 2013
        
      在 config/application.rb 里增加以下配置就可以了
config.time_zone = 'Beijing'
另外,rake time:zones:all 可以查看所有的时区
user.updated_at.localtime
 => 2013-07-26 22:17:27 +0800
但是不能保存不了
2.0.0p247 :027 > user.save
   (0.0ms)  SAVEPOINT active_record_1
   (0.3ms)  RELEASE SAVEPOINT active_record_1
 => true 
2.0.0p247 :028 > user.updated_at
 => Fri, 26 Jul 2013 14:17:27 UTC +00:00
          2.0.0p247 :012 > User.all
  User Load (0.0ms)  SELECT "users".* FROM "users"
 => #<ActiveRecord::Relation [#<User id: 1, name: "Michael Hartl", email: "[email protected]", created_at: "2013-07-26 14:53:20", updated_at: "2013-07-26 14:53:20">, #<User id: 2, name: "A Nother", email: "[email protected]", created_at: "2013-07-26 14:54:13", updated_at: "2013-07-26 14:54:13">]>
          rails 的设计是保存 UTC 时间 然后根据你的 local 显示不同的 local 时间 为了做倒 i18n 如果你强烈要求保存的时间就是你的 local 时间 那么请偷偷的在 application.rb 里面加上如下秘籍
config.time_zone = 'Beijing' # or other
config.active_record.default_timezone = :local
config.active_record.time_zone_aware_attributes = false