title: Rails error with CarrierWave and S3 on Heroku, TypeError: no implicit conversion of nil into String
body: <p>I am unable to upload images using CarrierWave and S3. I am using these gems:</p>
  
  <pre><code>gem 'carrierwave'
  gem 'carrierwave-aws'
  </code></pre>
  
  <p>I have the configuration set up properly, in the code, environment variables, and on AWS:</p>
  
  <pre><code>CarrierWave.configure do |config|
    config.storage    = :aws
    config.aws_bucket = ENV["S3_BUCKET_NAME"]
    config.aws_acl    = 'public-read'
    config.aws_credentials = {
      access_key_id:     ENV["AWS_ACCESS_KEY_ID"],
      secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
      region:            ENV["AWS_REGION"]
    }
    config.cache_dir = "#{Rails.root}/tmp/uploads"
  end
  
  class ImageUploader &lt; CarrierWave::Uploader::Base
    storage :aws
  
    def store_dir
      "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
    end
  
    def cache_dir
      "#{Rails.root}/tmp/uploads"
    end
  end
  </code></pre>
  
  <p>One source said to include the cache_dir lines specifically for Heroku inside the uploader, but it seems to have no effect:</p>
  
  <p><a href="https://github.com/carrierwaveuploader/carrierwave/wiki/how-to%3A-make-carrierwave-work-on-heroku" rel="nofollow">https://github.com/carrierwaveuploader/carrierwave/wiki/how-to%3A-make-carrierwave-work-on-heroku</a></p>
  
  <p>Here is some standard code to save an image, but it gives an error: </p>
  
  <pre><code>&gt; url = "https://dl.dropboxusercontent.com/u/22125572/Kira_opt.jpg"
  &gt; image = open(url)
  &gt; user = User.first
  &gt; user.image = image
  TypeError: no implicit conversion of nil into String
  from /app/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/uploader/cache.rb:171:in `join'
  from /app/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/uploader/cache.rb:171:in `cache_path'
  from /app/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/uploader/cache.rb:143:in `block in cache!'
  from /app/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/uploader/callbacks.rb:17:in `with_callbacks'
  from /app/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/uploader/cache.rb:134:in `cache!'
  from /app/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/mount.rb:329:in `cache'
  from /app/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/mount.rb:163:in `image='
  from /app/vendor/bundle/ruby/2.2.0/gems/carrierwave-0.11.2/lib/carrierwave/orm/activerecord.rb:39:in `image='
  from (irb):4
  from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/console.rb:110:in `start'
  from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/console.rb:9:in `start'
  from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:68:in `console'
  from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
  from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands.rb:17:in `&lt;top (required)&gt;'
  from bin/rails:9:in `require'
  from bin/rails:9:in `&lt;main&gt;'
  </code></pre>