gpt4 book ai didi

ruby-on-rails - Rails Devise Gem, (undefined method `to_datetime' for nil :NilClass) when i want to recover a password

转载 作者:数据小太阳 更新时间:2023-10-29 08:59:57 25 4
gpt4 key购买 nike

我在使用 Devise Gem 时遇到问题,我正在使用默认的可恢复方法,正在发送链接。重置值 (reset_password_sent_at) 保存在数据库中,但是当我必须记下新密码并更新它时,出现此错误

NoMethodError (undefined method `to_datetime' for nil:NilClass):
activesupport (4.0.2) lib/active_support/core_ext/date_time/calculations.rb:161:in `<=>'
activesupport (4.0.2) lib/active_support/core_ext/time/calculations.rb:286:in `compare_with_coercion'
activesupport (4.0.2) lib/active_support/time_with_zone.rb:214:in `<=>'
activerecord (4.0.2) lib/active_record/attribute_methods/dirty.rb:97:in `=='
activerecord (4.0.2) lib/active_record/attribute_methods/dirty.rb:97:in `!='
activerecord (4.0.2) lib/active_record/attribute_methods/dirty.rb:97:in `_field_changed?'
activerecord (4.0.2) lib/active_record/attribute_methods/dirty.rb:66:in `write_attribute'
activerecord (4.0.2) lib/active_record/attribute_methods/time_zone_conversion.rb:39:in `reset_password_sent_at='
devise (3.5.6) lib/devise/models/recoverable.rb:94:in `clear_reset_password_token'
devise (3.5.6) lib/devise/models/recoverable.rb:32:in `block (2 levels) in <module:Recoverable>'
activesupport (4.0.2) lib/active_support/callbacks.rb:377:in `_run__1626105923374900797__update__callbacks'
activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks'
activerecord (4.0.2) lib/active_record/callbacks.rb:310:in `update_record'
activerecord (4.0.2) lib/active_record/timestamp.rb:70:in `update_record'
activerecord (4.0.2) lib/active_record/persistence.rb:477:in `create_or_update'
activerecord (4.0.2) lib/active_record/callbacks.rb:302:in `block in create_or_update'
activesupport (4.0.2) lib/active_support/callbacks.rb:393:in `_run__1626105923374900797__save__callbacks'
activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks'
activerecord (4.0.2) lib/active_record/callbacks.rb:302:in `create_or_update'
activerecord (4.0.2) lib/active_record/persistence.rb:106:in `save'
activerecord (4.0.2) lib/active_record/validations.rb:51:in `save'
activerecord (4.0.2) lib/active_record/attribute_methods/dirty.rb:32:in `save'
activerecord (4.0.2) lib/active_record/transactions.rb:270:in `block (2 levels) in save'
activerecord (4.0.2) lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
activerecord (4.0.2) lib/active_record/transactions.rb:209:in `transaction'
activerecord (4.0.2) lib/active_record/transactions.rb:323:in `with_transaction_returning_status'
activerecord (4.0.2) lib/active_record/transactions.rb:270:in `block in save'
activerecord (4.0.2) lib/active_record/transactions.rb:281:in `rollback_active_record_state!'
activerecord (4.0.2) lib/active_record/transactions.rb:269:in `save'
devise (3.5.6) lib/devise/models/recoverable.rb:48:in `reset_password'
devise (3.5.6) lib/devise/models/recoverable.rb:141:in `reset_password_by_token'
devise (3.5.6) app/controllers/devise/passwords_controller.rb:32:in `update'

调试它似乎是一个问题,重置密码时 reset_password_sent_at 为 nil (lib/devise/models/recoverable.rb:94:inclear_reset_password_token)

我尝试将本地时间更改为存储的 UTC,但问题不在于此。有什么建议吗?

最佳答案

我的解决方案是将我的 Rails 从 4.0.2 升级到 4.2.7。当我运行捆绑安装并更新 gemfile 依赖项时,现在可以正常工作了。

将设备从 (3.5.6) 升级到 (4.2.0)

关于ruby-on-rails - Rails Devise Gem, (undefined method `to_datetime' for nil :NilClass) when i want to recover a password,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38260306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com