4

Unexpectedly today, I started getting the following error when trying to upload a photo to my app using Carrerwave and Fog. It had been working just fine:

NoMethodError (undefined method `content_length' for nil:NilClass)

This is the first time I've received the error, and it only happens when using fog for storage. I thought it may have had something to do with caching my User model that is associated with the photo, but I turned off caching temporarily and the problem persists. It definitely seems related to this problem last commented on 8 days ago.

The problem happens in my app or even in my Rails console after trying to save:

u = User.new
u.photo = File.open('somewhere.jpg')
u.save!

   (0.4ms)  ROLLBACK
NoMethodError: undefined method `content_length' for nil:NilClass

Here's the full trace

NoMethodError: undefined method `content_length' for nil:NilClass
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/carrierwave-0.10.0/lib/carrierwave/storage/fog.rb:239:in `size'
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/carrierwave-0.10.0/lib/carrierwave/uploader/proxy.rb:57:in `size'
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/carrierwave-0.10.0/lib/carrierwave/sanitized_file.rb:96:in `size'
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/carrierwave-0.10.0/lib/carrierwave/sanitized_file.rb:136:in `empty?'
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/carrierwave-0.10.0/lib/carrierwave/uploader/cache.rb:119:in `cache!'
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/carrierwave-0.10.0/lib/carrierwave/mount.rb:329:in `cache'
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/carrierwave-0.10.0/lib/carrierwave/mount.rb:163:in `photo='
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/carrierwave-0.10.0/lib/carrierwave/orm/activerecord.rb:39:in `photo='
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/counter_culture-0.1.30/lib/counter_culture.rb:345:in `block in previous_model'
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/counter_culture-0.1.30/lib/counter_culture.rb:344:in `each_pair'
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/counter_culture-0.1.30/lib/counter_culture.rb:344:in `previous_model'
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/counter_culture-0.1.30/lib/counter_culture.rb:260:in `block (2 levels) in _update_counts_after_update'
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/counter_culture-0.1.30/lib/counter_culture.rb:257:in `each'
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/counter_culture-0.1.30/lib/counter_culture.rb:257:in `block in _update_counts_after_update'
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/counter_culture-0.1.30/lib/counter_culture.rb:229:in `call'
    from /Users/paulosetinsky/.rvm/gems/ruby-2.1.1/gems/counter_culture-0.1.30/lib/counter_culture.rb:229:in `_wrap_in_counter_culture_active'

Appreciate any help!

po.studio
  • 4,007
  • 5
  • 25
  • 37
  • 1
    just realized this might be the culprit: https://github.com/carrierwaveuploader/carrierwave/commit/bbef19cc90c504d5cdfe8e34303a20f99fe4c453 – po.studio Feb 27 '15 at 00:45
  • Yeah, that looks like a fairly likely culprit. – geemus Feb 27 '15 at 21:27
  • @PaulOsetinsky you found a culprit, but what did you do about it? – ZuzannaSt Dec 22 '15 at 08:48
  • Did you find a solution to this problem? – Mel Jan 07 '16 at 21:15
  • @ZuzannaSt try using that new commit that i mentioned in the comment above that addressed the issue! https://github.com/carrierwaveuploader/carrierwave/commit/bbef19cc90c504d5cdfe8e34303a20f99fe4c453 – po.studio Jan 12 '16 at 17:05

0 Answers0