DB(来自架构)中有这样的行:
t.datetime "password_link_sent_at"
回调:
self.password_link_sent_at = Time.now
但输出错误:
Started PUT "/email_password" for 127.0.0.1 at 2013-05-22 03:22:42 +0400
Processing by SignsController#email_password as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"10qxpSGYRAKs/SqbWyG2IstRxpIe4VoOT96hNANq9Tk=", "email_reset"=>"user_mail@mail.ru", "commit"=>"Reset Password"}
User Load (6.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'user_mail@mail.ru' LIMIT 1
User Exists (1.0ms) SELECT 1 AS one FROM "users" WHERE "users"."password_reset_token" = '2kE2dtwlnsMrnCGTIGuCvQ' LIMIT 1
(1.0ms) BEGIN
(1.0ms) UPDATE "users" SET "password_reset_token" = '2kE2dtwlnsMrnCGTIGuCvQ', "password_link_sent_at" = '2013-05-21 23:22:43.167461', "updated_at" = '2013-05-21 23:22:43.175461' WHERE "users"."id" = 1
(5.0ms) COMMIT
Rendered user_mailer/password_reset.text.erb (1.0ms)
注意请求时间,并注意password_link_sent_at
本身的更新时间。
这是4个小时之前的事。
答案 0 :(得分:2)
您可能在UTC中以数据库存储时间,这是一件好事。
日志设置为当地时间。
通常将时间存储为UTC并转换以用于显示目的。这使您的数据库时区中立。
答案 1 :(得分:0)
self.password_link_sent_at = Time.zone.now
在这里查看信息http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html
答案 2 :(得分:0)
我不确定这个,但更改您的应用程序时区设置可能会有所帮助:
在config / application.rb
中config.time_zone = 'Prague'