title: rails: Breaking Heroku app while trying to add AWS S3 and carrierwave
body: <p><strong>Update:</strong></p>
  
  <p>it's really weird. I made a new app quickly and actually uploaded a file, but then I realized I had forgot to change storage :file to storage :fog. When I made that change to storage :fog, this new app broke github.com/MikeOnRails/s3 How could that one change break an app? </p>
  
  <p>Original Question</p>
  
  <p>I keep breaking and making new heroku apps trying to figure out how to get Amazon s3 to work with carrier wave. </p>
  
  <p>I found some instructions on the carrier wave git hub page but maybe I'm doing something. Carrier. I added my environment variables without problem (i.e. site didn't break)</p>
  
  <p>heroku config:add S3_KEY=NOTREAL8844848L S3_SECRET=NOTREAL345566</p>
  
  <p>then i created a file in the initializers directory called carrierwave_s3.rb and put this code in it</p>
  
  <pre><code>CarrierWave.configure do |config|
    config.fog_credentials = {
      :provider               =&gt; 'AWS',
      :aws_access_key_id      =&gt; ENV['S3_KEY'],
      :aws_secret_access_key  =&gt; ENV['S3_SECRET'],
      :region                 =&gt; 'US-Standard'
    }
    config.fog_directory  = 'm73test'
    config.fog_host       = 'https://m73test.s3.amazonaws.com'
    config.fog_public     = true
    config.fog_attributes = {'Cache-Control' =&gt; 'max-age=315576000'}
  end
  </code></pre>
  
  <p>I also tried putting single quotes around the ENV variables </p>
  
  <pre><code> :aws_access_key_id      =&gt; 'ENV['S3_KEY']',
      :aws_secret_access_key  =&gt; 'ENV['S3_SECRET']',
  </code></pre>
  
  <p>In uploaders/image_uploader.rb</p>
  
  <p>I changed </p>
  
  <pre><code>storage :file
  </code></pre>
  
  <p>to </p>
  
  <pre><code>storage :fog
  </code></pre>
  
  <p>Note,  <code>in uploaders/image_uploader.rb</code>I didn't change this at all, assuming that it needs a file path to store it at</p>
  
  <pre><code>def store_dir
      "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
    end
  </code></pre>
  
  <p>Then I pushed the new code and I got an application error.  Can anyone help? </p>
  
  <p>(Note,in the amazon console, when I create a bucket, it says "US Standard". I put the hyphen in my code because I saw that on the carrier wave git hub.)</p>
  
  <p>part of the Heroku logs telling me there's been a crash</p>
  
  <pre><code>4T23:32:03+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize'
  2012-01-14T23:32:03+00:00 app[web.1]:   from /app/config.ru:1:in `new'
  2012-01-14T23:32:03+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/server.rb:301:in `wrapped_app'
  2012-01-14T23:32:03+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:49:in `tap'
  2012-01-14T23:32:03+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:49:in `&lt;top (required)&gt;'
  2012-01-14T23:32:03+00:00 app[web.1]:   from script/rails:6:in `require'
  2012-01-14T23:32:03+00:00 app[web.1]:   from script/rails:6:in `&lt;main&gt;'
  2012-01-14T23:32:03+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/server.rb:252:in `start'
  2012-01-14T23:32:03+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.6/lib/rack/builder.rb:40:in `eval'
  2012-01-14T23:32:03+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:54:in `block in &lt;top (required)&gt;'
  2012-01-14T23:32:05+00:00 heroku[web.1]: State changed from starting to crashed
  2012-01-14T23:32:05+00:00 heroku[web.1]: Process exited
  2012-01-14T23:32:06+00:00 heroku[router]: Error H10 (App crashed) -&gt; GET mmcarry.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
  2012-01-14T23:32:06+00:00 heroku[router]: Error H10 (App crashed) -&gt; GET mmcarry.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=
  2012-01-14T23:32:11+00:00 heroku[router]: Error H10 (App crashed) -&gt; GET mmcarry.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
  2012-01-14T23:32:11+00:00 heroku[router]: Error H10 (App crashed) -&gt; GET mmcarry.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=
  </code></pre>