设计更新密码NoMethodError(未定义的方法`to_datetime'对于nil:NilClass):

时间:2016-03-13 19:47:39

标签: ruby-on-rails ruby ruby-on-rails-3 devise

我使用设计视图重置用户密码 我发送了reset_password_token和新密码,我收到了此错误。

有什么想法吗?

我很乐意添加任何必要的细节。我使用rails 3.2 with devise' 3.5.6'

NoMethodError (undefined method `to_datetime' for nil:NilClass):
  activesupport (3.2.14) lib/active_support/core_ext/date_time/calculations.rb:141:in `<=>'
  activesupport (3.2.14) lib/active_support/core_ext/time/calculations.rb:359:in `compare_with_coercion'
  activesupport (3.2.14) lib/active_support/time_with_zone.rb:190:in `<=>'
  activerecord (3.2.14) lib/active_record/attribute_methods/dirty.rb:90:in `=='
  activerecord (3.2.14) lib/active_record/attribute_methods/dirty.rb:90:in `!='
  activerecord (3.2.14) lib/active_record/attribute_methods/dirty.rb:90:in `_field_changed?'
  activerecord (3.2.14) lib/active_record/attribute_methods/serialization.rb:97:in `_field_changed?'
  activerecord (3.2.14) lib/active_record/attribute_methods/dirty.rb:63:in `write_attribute'
  activerecord (3.2.14) lib/active_record/attribute_methods/time_zone_conversion.rb:47: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 (3.2.14) lib/active_support/callbacks.rb:407:in `_run__312818332643827378__update__4267586685858662397__callbacks'
  activesupport (3.2.14) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.14) lib/active_support/callbacks.rb:385:in `_run_update_callbacks'
  activesupport (3.2.14) lib/active_support/callbacks.rb:81:in `run_callbacks'
  activerecord (3.2.14) lib/active_record/callbacks.rb:272:in `update'
  activerecord (3.2.14) lib/active_record/persistence.rb:348:in `create_or_update'
  activerecord (3.2.14) lib/active_record/callbacks.rb:264:in `block in create_or_update'
  activesupport (3.2.14) lib/active_support/callbacks.rb:414:in `_run__312818332643827378__save__4267586685858662397__callbacks'
  activesupport (3.2.14) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.14) lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
  activesupport (3.2.14) lib/active_support/callbacks.rb:81:in `run_callbacks'
  activerecord (3.2.14) lib/active_record/callbacks.rb:264:in `create_or_update'
  activerecord (3.2.14) lib/active_record/persistence.rb:84:in `save'
  activerecord (3.2.14) lib/active_record/validations.rb:50:in `save'
  activerecord (3.2.14) lib/active_record/attribute_methods/dirty.rb:22:in `save'
  activerecord (3.2.14) lib/active_record/transactions.rb:259:in `block (2 levels) in save'
  activerecord (3.2.14) lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
  activerecord (3.2.14) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
  activerecord (3.2.14) lib/active_record/transactions.rb:208:in `transaction'
  activerecord (3.2.14) lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
  activerecord (3.2.14) lib/active_record/transactions.rb:259:in `block in save'
  activerecord (3.2.14) lib/active_record/transactions.rb:270:in `rollback_active_record_state!'
  activerecord (3.2.14) lib/active_record/transactions.rb:258:in `save'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/active_record_helper.rb:26:in `block in save'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/transaction.rb:848:in `with_database_metric_name'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent.rb:572:in `with_database_metric_name'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/active_record_helper.rb:25: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'
  actionpack (3.2.14) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (3.2.14) lib/abstract_controller/base.rb:167:in `process_action'
  actionpack (3.2.14) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (3.2.14) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  activesupport (3.2.14) lib/active_support/callbacks.rb:447:in `_run__1749634817633484351__process_action__1911466050157971041__callbacks'
  activesupport (3.2.14) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.14) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  activesupport (3.2.14) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.14) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.14) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.14) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  activesupport (3.2.14) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.14) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.14) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.14) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  activerecord (3.2.14) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:30:in `block in process_action'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:362:in `perform_action_with_newrelic_trace'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:25:in `process_action'
  actionpack (3.2.14) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.14) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.14) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.14) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.14) lib/action_controller/metal.rb:246:in `block in action'
  actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:36:in `call'
  actionpack (3.2.14) lib/action_dispatch/routing/mapper.rb:43:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `each'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.14) lib/action_dispatch/routing/route_set.rb:608:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/rack/browser_monitoring.rb:32:in `traced_call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/rack/developer_mode.rb:48:in `traced_call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.6) lib/warden/manager.rb:34:in `catch'
  warden (1.2.6) lib/warden/manager.rb:34:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (1.4.7) lib/rack/etag.rb:23:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (1.4.7) lib/rack/conditionalget.rb:35:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/head.rb:14:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/flash.rb:242:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (1.4.7) lib/rack/session/abstract/id.rb:210:in `context'
  rack (1.4.7) lib/rack/session/abstract/id.rb:205:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/cookies.rb:341:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  activerecord (3.2.14) lib/active_record/query_cache.rb:64:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  activerecord (3.2.14) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.14) lib/active_support/callbacks.rb:405:in `_run__349007920982004187__call__4267586685858662397__callbacks'
  activesupport (3.2.14) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.14) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.14) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.14) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  railties (3.2.14) lib/rails/rack/logger.rb:32:in `call_app'
  railties (3.2.14) lib/rails/rack/logger.rb:16:in `block in call'
  activesupport (3.2.14) lib/active_support/tagged_logging.rb:22:in `tagged'
  railties (3.2.14) lib/rails/rack/logger.rb:16:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (1.4.7) lib/rack/methodoverride.rb:21:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (1.4.7) lib/rack/runtime.rb:17:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  activesupport (3.2.14) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (1.4.7) lib/rack/lock.rb:15:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (3.2.14) lib/action_dispatch/middleware/static.rb:63:in `call'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  railties (3.2.14) lib/rails/engine.rb:484:in `call'
  railties (3.2.14) lib/rails/application.rb:231:in `call'
  railties (3.2.14) lib/rails/railtie/configurable.rb:30:in `method_missing'
  newrelic_rpm (3.15.0.314) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (1.4.7) lib/rack/content_length.rb:14:in `call'
  railties (3.2.14) lib/rails/rack/log_tailer.rb:17:in `call'
  rack (1.4.7) lib/rack/handler/webrick.rb:59:in `service'
  /Users/uriklar/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
  /Users/uriklar/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
  /Users/uriklar/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'


  Rendered /Users/uriklar/.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.14/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.1ms)
  Rendered /Users/uriklar/.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.14/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms)
  Rendered /Users/uriklar/.rvm/gems/ruby-2.3.0/gems/actionpack-3.2.14/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (50.4ms)
^[[1;2D

2 个答案:

答案 0 :(得分:1)

好的,显然这是可以做的事情: 我使用的是letter_opener,因此密码重置电子邮件实际上并未发送 时间不能在我的开发机器上正确设置

答案 1 :(得分:1)

我发现了一个类似的问题,我的&#34; RAILS_ENV =开发包exec rake db:drop db:create db:migrate db:seed&#34;命令工作将与ruby 2.2.3p173,但与ruby 2.3.0p0,它会抛出以下错误:

rake aborted!
NoMethodError: undefined method `to_datetime' for nil:NilClass
.../.rvm/gems/ruby-2.3.0@atlantis/gems/activesupport-3.2.17/lib/active_support/core_ext/date_time/calculations.rb:141:in `<=>'