[Backgroundrb-devel] Inconsistent Model creation behavior

Benjamin H. Bryant iambenbryant at gmail.com
Thu Jan 17 03:46:44 EST 2008


Hi,

I have a relatively simple Worker: (I added the line numbers to the  
email, they are not in the worker)

#####################################################################################

class ImagetestWorker < BackgrounDRb::MetaWorker

   set_worker_name :imagetest_worker
   def create(args = nil)

   end

   def save_image(args)

     @newbook = Book.new
     @newbook.comment = "hello"
     @newbook.save

  14   @newerimage = Image.new
  15   @newerimage.user_id = args[:user_id]
  16   @newerimage.uploaded_data = args[:temppath]
         @newerimage.save

   end

end

#####################################################################################

It will create and save the Book object without problems.  However, it  
will not create the Image object and instead I receive this error:

#####################################################################################

workers/imagetest_worker.rb:15:in `save_image': You have a nil object  
when you didn't expect it! (NoMethodError)
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]	from /Users/BBryant/Sites/ 
date_site/trunk/vendor/plugins/backgroundrb/server/meta_worker.rb: 
223:in `send'
	from /Users/BBryant/Sites/date_site/trunk/vendor/plugins/backgroundrb/ 
server/meta_worker.rb:223:in `process_request'
	from /Users/BBryant/Sites/date_site/trunk/vendor/plugins/backgroundrb/ 
server/meta_worker.rb:207:in `receive_data'
	from /Users/BBryant/Sites/date_site/trunk/vendor/plugins/backgroundrb/ 
framework/worker.rb:54:in `receive_internal_data'
	from /Users/BBryant/Sites/date_site/trunk/vendor/plugins/BackgrounDRB/ 
lib/../framework/bin_parser.rb:29:in `call'
	from /Users/BBryant/Sites/date_site/trunk/vendor/plugins/BackgrounDRB/ 
lib/../framework/bin_parser.rb:29:in `extract'
	from /Users/BBryant/Sites/date_site/trunk/vendor/plugins/backgroundrb/ 
framework/worker.rb:52:in `receive_internal_data'
	from /Users/BBryant/Sites/date_site/trunk/vendor/plugins/backgroundrb/ 
framework/worker.rb:48:in `handle_internal_messages'
	 ... 10 levels...
	from /Users/BBryant/Sites/date_site/trunk/vendor/plugins/backgroundrb/ 
framework/packet_master.rb:19:in `run'
	from /Users/BBryant/Sites/date_site/trunk/vendor/plugins/backgroundrb/ 
server/master_worker.rb:163:in `initialize'
	from script/backgroundrb:41:in `new'
	from script/backgroundrb:41

####################################################################################

I can create and save an instance of the Image model from a controller  
without problems.
This is driving me crazy.

Thanks in advance.

Ben



More information about the Backgroundrb-devel mailing list