我的delayed_job失败了一个奇怪的错误。我已经完成了这些步骤,没有任何失败。我在我的测试服务器上运行它,没有任何失败。但在生产方面,某种数据正在摇摆不定。有什么想法吗?
Email(#-616792908) expected, got NilClass(#-605566518)\n/data/HQ_Channel2/releases/20110610192557/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:263:in `raise_on_type_mismatch'\n/data/HQ_Channel2/releases/20110610192557/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:117:in `<<'\n/data/HQ_Channel2/releases/20110610192557/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:116:in `each'\n/data/HQ_Channel2/releases/20110610192557/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:116:in `<<'\n/data/HQ_Channel2/releases/20110610192557/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:141:in `transaction'\n/data/HQ_Channel2/releases/20110610192557/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'\n/data/HQ_Channel2/releases/20110610192557/vendor/rails/activerecord/lib/active_record/transactions.rb:182:in `transaction'\n/data/HQ_Channel2/releases/20110610192557/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:140:in `transaction'\n/data/HQ_Channel2/releases/20110610192557/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:115:in `<<'\n/data/HQ_Channel2/releases/20110610192557/lib/magic_email.rb:11:in `perform'\n/data/HQ_Channel2/releases/20110610192557/lib/magic_email.rb:8:in `each'\n/data/HQ_Channel2/releases/20110610192557/lib/magic_email.rb:8:in `perform'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/backend/base.rb:53:in `invoke_job'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/worker.rb:108:in `run'\n/usr/lib/ruby/1.8/timeout.rb:67:in `timeout'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/worker.rb:108:in `run'\n/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/worker.rb:107:in `run'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/worker.rb:162:in `reserve_and_run_one_job'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/worker.rb:92:in `work_off'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/worker.rb:91:in `times'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/worker.rb:91:in `work_off'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/worker.rb:66:in `start'\n/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/worker.rb:65:in `start'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/worker.rb:62:in `loop'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/worker.rb:62:in `start'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/command.rb:69:in `run'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/command.rb:46:in `daemonize'\n/data/HQ_Channel2/releases/20110610192557/vendor/gems/daemons-1.0.10/lib/daemons/application.rb:215:in `call'\n/data/HQ_Channel2/releases/20110610192557/vendor/gems/daemons-1.0.10/lib/daemons/application.rb:215:in `start_proc'\n/data/HQ_Channel2/releases/20110610192557/vendor/gems/daemons-1.0.10/lib/daemons/daemonize.rb:192:in `call'\n/data/HQ_Channel2/releases/20110610192557/vendor/gems/daemons-1.0.10/lib/daemons/daemonize.rb:192:in `call_as_daemon'\n/data/HQ_Channel2/releases/20110610192557/vendor/gems/daemons-1.0.10/lib/daemons/application.rb:219:in `start_proc'\n/data/HQ_Channel2/releases/20110610192557/vendor/gems/daemons-1.0.10/lib/daemons/application.rb:255:in `start'\n/data/HQ_Channel2/releases/20110610192557/vendor/gems/daemons-1.0.10/lib/daemons/controller.rb:69:in `run'\n/data/HQ_Channel2/releases/20110610192557/vendor/gems/daemons-1.0.10/lib/daemons.rb:188:in `run_proc'\n/data/HQ_Channel2/releases/20110610192557/vendor/gems/daemons-1.0.10/lib/daemons/cmdline.rb:105:in `call'\n/data/HQ_Channel2/releases/20110610192557/vendor/gems/daemons-1.0.10/lib/daemons/cmdline.rb:105:in `catch_exceptions'\n/data/HQ_Channel2/releases/20110610192557/vendor/gems/daemons-1.0.10/lib/daemons.rb:187:in `run_proc'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/command.rb:45:in `daemonize'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/command.rb:43:in `times'\n/data/HQ_Channel2/releases/20110610192557/vendor/plugins/delayed_job/lib/delayed/command.rb:43:in `daemonize'\nscript
假设这是一个关联问题,我的HABTM就有一点背景......
class Email < ActiveRecord::Base
has_and_belongs_to_many :card_signups
end
class CardSignup < ActiveRecord::Base
has_and_belongs_to_many :emails
end
答案 0 :(得分:4)
好的,所以我以一种奇怪的方式解决了这种情况,而且我非常乐意向某人解释为什么这会解决它,但这就是我以前所拥有的:
CardSignup.find_by_email(email).emails << orig_email
这是导致错误的原因。这就是修正它的原因:
CardSignup.find_by_email(email).emails << Email.find(orig_email.id)
由于某些原因,Delayed_Jobs无法对原始对象进行查询?