有這樣一行DB(從模式):錯誤Time.now輸出
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"=>"[email protected]", "commit"=>"Reset Password"}
User Load (6.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = '[email protected]' 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小時前。
'如果@user && Time.zone.now - @ user.password_link_sent_at <2.hours'代替'@ user.password_link_sent_at <2.hours.ago'似乎在工作 –