Question

I'm using delayed job to handle some imaging processing. I would like to be able to just hand it the pointer to the file on the users system # But it cannot encode it correctly, or it's trying to encode the entire file.

I'm trying t avoid copying the file to the db, then writing it back out. before i suck it into the ImageMagick process.

specifically i get this trace

2014-04-27 22:05:39.614 [fyi] Completed 500 Internal Server Error in 818122ms (pid:14469)
2014-04-27 22:05:39.622 [omg] NoMethodError - undefined method `name' for nil:NilClass:
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:50:in `block in initialize'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:52:in `block in initialize'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:52:in `block in initialize'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:52:in `block in initialize'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:52:in `block in initialize'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:128:in `accept'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:344:in `block in visit_Array'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:344:in `visit_Array'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:128:in `accept'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:467:in `block in emit_coder'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:465:in `emit_coder'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:450:in `dump_coder'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:126:in `accept'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:92:in `push'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:244:in `dump'
  /Users/bobby/.rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/core_ext.rb:14:in `psych_to_yaml'
  delayed_job (4.0.1) lib/delayed/backend/base.rb:85:in `payload_object='
  activerecord (4.1.0) lib/active_record/attribute_assignment.rb:45:in `_assign_attribute'
  activerecord (4.1.0) lib/active_record/attribute_assignment.rb:32:in `block in assign_attributes'
  activerecord (4.1.0) lib/active_record/attribute_assignment.rb:26:in `assign_attributes'
  activerecord (4.1.0) lib/active_record/core.rb:452:in `init_attributes'
  activerecord (4.1.0) lib/active_record/core.rb:198:in `initialize'
  oink (0.10.1) lib/oink/instrumentation/active_record.rb:60:in `initialize'
  activerecord (4.1.0) lib/active_record/inheritance.rb:30:in `new'
  delayed_job (4.0.1) lib/delayed/backend/base.rb:29:in `enqueue'
  delayed_job (4.0.1) lib/delayed/message_sending.rb:12:in `method_missing'

my command to push job to delayed job is here.

Was it helpful?

Solution

Okay, I realize this was wishful thinking. The browsers, in order to protect the user's PC, copy the file to the tmp directory on the server before they let you touch it. So that means that delay job cannot access it since the worker is a unique instance of your app, which typically means that it has it's own tmp directory, so the file isn't going to be there. To solve this, i wound up just using Amazon S3. I already save the file there, so i just load it back. Other I see save the file into the database so they can grab it form there since that the only shared store that exists in the rails app. I just cringe at throwing a 4-40MB image file into the database.

OTHER TIPS

I had the same issue.

It was happening because I was writing an object into a ActiveRecord attribute with:

write_attribute(:picture, @uploader)

@uploader being in one case a String (this is working perfectly) and in some other case, my object Uploader (that was raising this error).

The fix was not to ever write an object into a ActiveRecord field that is supposed to contain a String anyway.

Hope it would help. =)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top