My delayed_job is failing with a bizarre error. I've run through the steps, and nothing fails. I run this on my testing server and nothing fails. But on production, some sort of piece of data is rocking the boat here. Any ideas?
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 开发者_StackOverflow`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
Assuming this is an association problem here's a little background on my HABTM..
class Email < ActiveRecord::Base
has_and_belongs_to_many :card_signups
end
class CardSignup < ActiveRecord::Base
has_and_belongs_to_many :emails
end
Ok so I resolved this situation in an odd way, and I'm very much so open to someone explaining why this resolved it but this is what I used to have :
CardSignup.find_by_email(email).emails << orig_email
This is what caused the error. And this is what fixed it:
CardSignup.find_by_email(email).emails << Email.find(orig_email.id)
For some reason Delayed_Jobs can not do a query on a raw object?
精彩评论