delayed_paperclip icon indicating copy to clipboard operation
delayed_paperclip copied to clipboard

undefined method `[]' for nil:NilClass

Open dennismonsewicz opened this issue 11 years ago • 2 comments

Here is the full stack trace from Sidekiq

Athlete Load (1.0ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN ('Athlete') AND "users"."id" = $1 LIMIT 1  [["id", 58]]
2013-08-17T02:34:57Z 23360 TID-ov9eled40 DelayedPaperclip::Jobs::Sidekiq JID-7a14dd1ce33c1ce0b6911c83 INFO: fail: 0.008 sec
2013-08-17T02:34:57Z 23360 TID-ov9eled40 WARN: {"retry"=>true, "queue"=>"paperclip", "class"=>"DelayedPaperclip::Jobs::Sidekiq", "args"=>["Athlete", 58, "avatar"], "jid"=>"7a14dd1ce33c1ce0b6911c83", "enqueued_at"=>1376706897.139353, "error_message"=>"undefined method `[]' for nil:NilClass", "error_class"=>"NoMethodError", "failed_at"=>"2013-08-17T02:33:19Z", "retry_count"=>2, "retried_at"=>2013-08-17 02:34:57 UTC}
2013-08-17T02:34:57Z 23360 TID-ov9eled40 WARN: undefined method `[]' for nil:NilClass
2013-08-17T02:34:57Z 23360 TID-ov9eled40 WARN: /Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/delayed_paperclip-2.6.1/lib/delayed_paperclip/attachment.rb:45:in `process_delayed!'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/delayed_paperclip-2.6.1/lib/delayed_paperclip.rb:33:in `process_job'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/delayed_paperclip-2.6.1/lib/delayed_paperclip/jobs/sidekiq.rb:14:in `perform'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/processor.rb:48:in `block (3 levels) in process'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/middleware/chain.rb:109:in `call'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/middleware/chain.rb:109:in `block in invoke'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/newrelic_rpm-3.6.6.147/lib/new_relic/agent/instrumentation/sidekiq.rb:25:in `block in call'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/newrelic_rpm-3.6.6.147/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:318:in `perform_action_with_newrelic_trace'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/newrelic_rpm-3.6.6.147/lib/new_relic/agent/instrumentation/sidekiq.rb:24:in `call'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/middleware/chain.rb:111:in `block in invoke'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/middleware/chain.rb:111:in `block in invoke'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/middleware/server/retry_jobs.rb:49:in `call'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/middleware/chain.rb:111:in `block in invoke'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/logging.rb:22:in `with_context'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/middleware/server/logging.rb:7:in `call'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/middleware/chain.rb:111:in `block in invoke'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/middleware/chain.rb:114:in `call'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/middleware/chain.rb:114:in `invoke'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/processor.rb:47:in `block (2 levels) in process'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/processor.rb:102:in `stats'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/sidekiq-2.13.0/lib/sidekiq/processor.rb:46:in `block in process'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/celluloid-0.14.1/lib/celluloid/calls.rb:25:in `call'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/celluloid-0.14.1/lib/celluloid/calls.rb:25:in `public_send'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/celluloid-0.14.1/lib/celluloid/calls.rb:25:in `dispatch'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/celluloid-0.14.1/lib/celluloid/calls.rb:67:in `dispatch'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/celluloid-0.14.1/lib/celluloid/future.rb:15:in `block in new'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/celluloid-0.14.1/lib/celluloid/internal_pool.rb:59:in `call'
/Users/dennismonsewicz/.rvm/gems/ruby-1.9.3-p429@myapp/gems/celluloid-0.14.1/lib/celluloid/internal_pool.rb:59:in `block in create'

Here is my setup in my User model

has_attached_file :avatar, PAPERCLIP_OPTIONS.merge(
    :default_url => "//s3.amazonaws.com/bucket-name/media/avatar-placeholder.gif",
    :styles => {
      :"58x58"   => "35x35^",
      :"150x150" => "56x56^",
      :"184x185" => "165x110^",
      :"259x259" => "259x259^"
    },
    :convert_options => {
      :"58x58"   => "-background transparent -auto-orient -gravity center -extent 58x58",
      :"150x150" => "-background transparent -auto-orient -gravity center -extent 150x150",
      :"184x185" => "-background transparent -auto-orient -gravity center -extent 184x185",
      :"259x259" => "-background transparent -auto-orient -gravity center -extent 259x259"
    }
  )

  process_in_background :avatar

Gemfile:

gem 'paperclip', "3.4.2"
gem 'delayed_paperclip'

dennismonsewicz avatar Aug 17 '13 02:08 dennismonsewicz

Nevermind, I fixed it... I am using STI (Single Table Inheritance) in my app... so the Paperclip methods weren't available on the Athlete class

dennismonsewicz avatar Aug 17 '13 02:08 dennismonsewicz

@dennismonsewicz What did you do to fix it? call has_attached_file on all your subclasses?

danhixon avatar Jan 22 '14 22:01 danhixon