In the event that you are puttering through mhartl's fantastic RailsTutorial as I am and had the same "a ha" moment in Chapter 11 where you need to set up an Amazon S3 account to host your production environment's image uploads, I offer this quick gist (forked from derrek). The "a ha" moment?
Wondering if you can just use DreamObjects instead of S3, since you already use Dreamhost.
You'll be doing some changes with RailsTutorial's Listing 11.65, but it will stay mostly the same given the compatibility with the S3 API.
In the DreamObjects web GUI, if you don't already have a bucket, click "create bucket". Name the bucket. For this example the bucket is named testing-bucket. Click the link to "Change Settings" for the bucket and then toggle the "private" switch to "public".
The public key will be displayed under the user to whom the bucket belongs (if it doesn't, just click on the user's area and it will expand to show the user's details). Click on "Show Secret Key" (to the right of the public key in hardly legible light gray). This will reveal the private key.
edit config/initializers/carrier_wave.rb
if Rails.env.production?
CarrierWave.configure do |config|
config.fog_credentials = {
# Configuration for DreamObjects
:provider => "AWS",
:aws_access_key_id => ENV['S3_ACCESS_KEY'],
:aws_secret_access_key => ENV['S3_SECRET_KEY'],
:host => 'objects.dreamhost.com'
}
config.fog_directory = ENV['S3_BUCKET']
config.fog_public = true
config.asset_host = ENV['S3_ASSETS']
end
endYou'll then need to set up the Heroku ENV variables, which is almost the same with what's in the tutorial (omit the <>):
heroku config:set S3_ACCESS_KEY=<DreamObjects public key>
heroku config:set S3_SECRET_KEY=<DreamObjects private key>
heroku config:set S3_BUCKET=<DreamObjects bucket name, e.g., testing-bucket>
heroku config:set S3_ASSETS=<full URL to DreamObjects bucket, e.g., https://testing-bucket.objects.dreamhost.com>Now you can continue on your merry way with Chapter 11!