title: Troubles setting up Paperclip + AWS S3 for image storing in our Rails3/Heroku App
body: <p>We have already built a rails app that has several users and an image for each of them.  Doing all of the dev work on our localhost, we have working seeds for users &amp; photos...but now that we are trying to use S3 for the image storage, we are running into errors during...always during the "seed" step of the migrations, when doing this: </p>
  
  <blockquote>
    <p>rake db:migrate:reset</p>
  </blockquote>
  
  <p>Apologies for the question, but we have  have been banging our heads on this for 11 hours, having gone through every related Stack question on the subject.  A lot of similar posts had a NoSuchBucket error and other types of issues, but we none of the suggested changes have fixed our issue...maybe it's related to the newest versions of the gems we are using?</p>
  
  <p>We are using Rails 3.0.4, Ruby 1.8.7, Paperclip 2.3.8, aws-s3 0.6.2</p>
  
  <p>We are adding seeds for initial users and a photo for each user using our seeds.rb file in the /migrate/ folder.   This always worked fine when storing files and images on local machine (using paperclip, but not S3).  We also have tested removing the seeds file and simply creating a new user with the working app and got the same error:</p>
  
  <blockquote>
    <p>Credentials are not a path, file, or
    hash</p>
  </blockquote>
  
  <p>For the user module, we have tested both the option where we set the following S3 keys through both the (a) yml file and (b) directly in the user model. 
  access_key_id: 'secret'
  secret_access_key: 'secret' </p>
  
  <p>We have tried doing this from our localhost (not yet live on heroku), and we have also tried running this through Heroku.  </p>
  
  <p>We have tried seemingly every permutation of the layout of those keys, but the error we most frequently get is this:</p>
  
  <blockquote>
    <p>can't convert Module into Hash</p>
  </blockquote>
  
  <p>Googling this error message returns zero results, so we don't know what's happening there.  This was the most frustrating part...seemingly every attempt got us back to this error.</p>
  
  <p>We also tried both:</p>
  
  <p>(1) hardcoding the access keys in the user model, both like this:</p>
  
  <pre><code>:access_key_id =&gt; ENV['accesskeyid'],
  :secret_access_key =&gt; ENV['secretaccesskey'],
  </code></pre>
  
  <p>In this case, we often got this error:</p>
  
  <blockquote>
    <p>You did not provide both required access keys. Please provide the
    access_key_id and the secret_access_key.</p>
  </blockquote>
  
  <p>Frustrating, because we always had both items listed, tested with and without quotes, changing up the order, etc.</p>
  
  <p>We tried it both (a) with the ENV['accesskeyid'] and (b) without those...with simply 
      blahblah => 'accesskeyid'.</p>
  
  <p>and (2) putting the keys into the yml file, like this:</p>
  
  <pre><code>has_attached_file :photo,
    :storage =&gt; :s3,
    :s3_credentials =&gt; "#{Rails.root}/config/s3.yml",
    :path =&gt; "/:photo/:filename"
  </code></pre>
  
  <p>with this in the yml file:</p>
  
  <pre><code>development:
    access_key_id: accesskeyid
    secret_access_key: secretaccesskey
    bucket: ourbucketname
  production:
    access_key_id: accesskeyid
    secret_access_key: secretaccesskey
    bucket: ourbucketname
  </code></pre>
  
  <p>We tried this with single quotes around the keys, and without.  </p>
  
  <p>We also tried defining the bucket in the model, rather than in the yml file, and got the same error. </p>
  
  <p>and (3), setting it up this way: </p>
  
  <blockquote>
    <p>if Rails.env == "production"
         S3_CREDENTIALS = { :access_key_id => ENV['S3_KEY'], :secret_access_key => ENV['S3_SECRET'], :bucket => "ourbucket"}    else
         S3_CREDENTIALS = Rails.root.join("config/s3.yml")<br>
    end</p>
    
    <p>has_attached_file :photo,
          :storage => :s3,
          :styles => { :small => "50x50>", :thumb => "75x75>", :medium =>
    "400x400>"},
          :path => "/:photo/:filename"</p>
  </blockquote>
  
  <p>With the same contents in our yml file.</p>
  
  <p>This gave us this error:</p>
  
  <blockquote>
    <p>credentials are not a file, path, or hash</p>
  </blockquote>
  
  <p>Naturally, we quadruple-checked that we had the correct access keys (from our AWS account) and tested several different ways of setting up the hash, but never got what we wanted.</p>
  
  <p>Here is the relevant portion of Gemfile:
      gem 'aws-s3', :require => 'aws/s3'  #For Storing Images on Amazon
      gem 'paperclip'</p>
  
  <p>As another attempt, we tried to use the gem right_aws, instead, in the Gemfile, but this resulted in this error:  </p>
  
  <blockquote>
    <p>no such file to load -- aws/s3 (You
    may need to install the aws-s3 gem)</p>
  </blockquote>
  
  <p>Note, we have been doing all of this and hitting all of these errors doing migrations from from localhost, not from the live Heroku app, but couldn't even get past this simple 'seed users' step.   </p>
  
  <p>Currently, our bucket is titled media.oururl.com.  Is there some issue with having periods in the bucket name?</p>
  
  <p>Going to ask the heroku guys about this, as well, but considering how amazing this community is, I am hoping one of you knows what we're doing wrong her.</p>
  
  <p>MUCH appreciated - and hopefully this helps others who follow behind us.</p>