espen / balder

Balder - Open source Ruby on Rails photo gallery
http://balderapp.com
MIT License
263 stars 97 forks source link

Carrierwave 500s with "TypeError (no implicit conversion of nil into String)" when not on Heroku #43

Open rick opened 10 years ago

rick commented 10 years ago

I have a patch for this over in https://github.com/rick/balder/pull/1, specifically https://github.com/rick/balder/commit/81af9e7eedef9cf5a1d676213f888d6cfee40fa7 but I'm not clear on what the various concerns are (and whether this will break something for other folks).

I was seeing these sort of errors consistently:

TypeError (no implicit conversion of nil into String):
  app/controllers/photos_controller.rb:80:in `create'
  app/middleware/flash_session_cookie_middleware.rb:16:in `call'

The cache_dir method, which carrierwave seems to rely on, is only defined on Heroku + S3 configurations. It might actually need to be widened to be defined on all configurations, but I'm at least relying on S3 myself, so not sure.

espen commented 10 years ago

What server are you using? I would assume that the tmp directory would be writable otherwise (Heroku is sortof read-only).

rick commented 10 years ago

I'm on a digitalocean VPS for this installation, nginx + unicorn. The problem doesn't appear to be one of whether the temp directory is writeable, but rather one of the call to cache_dir from inside carrierwave blows up because there's no implementation of cache_dir in scope when using S3 but not using Heroku.

Would it be more appropriate to delegate to some other default in the non-Heroku case? I looked back at the history of the file and couldn't infer what the intent was when I tracked down the problem.

coneybeare commented 10 years ago

I am seeing this problem problem when uploading on a private server as well as localhost.

Completed 500 Internal Server Error in 952ms

TypeError (can't convert nil into String):
  app/controllers/photos_controller.rb:82:in `create'
  app/middleware/flash_session_cookie_middleware.rb:16:in `call'
espen commented 10 years ago

And it works when setting the tmp dir? I'm a bit confused with the error message if the problem is not being able to store to disk.

coneybeare commented 10 years ago

I am not sure that that is the problem, the error message is pretty vague. I am using s3 and not heroku, so maybe the cache_dir thing is the problem, maybe not. Is there anything you want me to experiment with to help debug?

espen commented 10 years ago

A full stack trace would help. Try changing this and see if that helps. https://github.com/rick/balder/commit/81af9e7eedef9cf5a1d676213f888d6cfee40fa7

coneybeare commented 10 years ago

Not necessary. I just commented out the cache_dir method and it worked. So the problem is that you are returning false from the cache_dir method in file_uploader.rb when not using heroku instead of calling super or the default it expects (I think).

coneybeare commented 10 years ago

Hm, spoke too soon. Worked locally, but not on the remote server.

coneybeare commented 10 years ago

Sorry for the smap, twas a caching issue. This fix works for me both locally and on my remote non-heroku server with s3