title: Rails 4.1 : Aws::Errors::MissingRegionError using Paperclip
body: <p>Using paperclip gem to upload images which works in development , but not in production.</p>
  
  <p><strong>Aws::Errors::MissingRegionError (missing region; use :region option or export region name to ENV['AWS_REGION']):</strong></p>
  
  <p>heroku conifg </p>
  
  <pre><code>AWS_ACCESS_KEY_ID:     &lt;Aws Access Key Id&gt;
  **AWS_REGION:            us-west-2**
  AWS_SECRET_ACCESS_KEY: &lt;Aws Secret Access Key&gt;
  DATABASE_URL:          postgres://be4A6l7VOXXs@ec2-54-83-36-203.compute-1.amazonaws.com:5432/d2g7h0v5
  LANG:                  en_US.UTF-8
  RACK_ENV:              production
  RAILS_ENV:             production
  S3_BUCKET_NAME:        &lt;Bucket Name&gt;
  </code></pre>
  
  <p>config.production file</p>
  
  <pre><code>config.paperclip_defaults = {
    :storage =&gt; :s3,
      :region =&gt; ENV['AWS_REGION'],
    :s3_credentials =&gt; {
      :bucket =&gt; ENV['S3_BUCKET_NAME'],
      :access_key_id =&gt; ENV['AWS_ACCESS_KEY_ID'],
      :secret_access_key =&gt; ENV['AWS_SECRET_ACCESS_KEY']
    }
  }
  </code></pre>
  
  <p>gemfile</p>
  
  <p>source '<a href="https://rubygems.org" rel="nofollow">https://rubygems.org</a>'</p>
  
  <pre><code>ruby '2.0.0'
  gem 'rails', '4.1.7'
  gem 'sqlite3', group: :development
  gem 'sass-rails', '~&gt; 4.0.3'
  gem 'uglifier', '&gt;= 1.3.0'
  gem 'coffee-rails', '~&gt; 4.0.0'
  gem 'jquery-rails'
  gem 'turbolinks'
  gem 'jbuilder', '~&gt; 2.0'
  gem 'sdoc', '~&gt; 0.4.0',          group: :doc
  gem 'spring',        group: :development
  gem 'simple_form'
  gem 'bootstrap-sass', '~&gt; 3.3.5'
  gem 'devise'
  **gem 'paperclip', github: 'thoughtbot/paperclip'
  **gem 'aws-sdk', '~&gt; 2.1', '&gt;= 2.1.31'****
  
  gem 'rails_12factor', group: :production
  gem 'pg', group: :production
  </code></pre>
  
  <p>updated config file </p>
  
  <pre><code>config.paperclip_defaults = {
    :storage =&gt; :s3,
       :s3_region =&gt; ENV['AWS_REGION'],
       :s3_credentials =&gt; {
       :bucket =&gt; ENV['S3_BUCKET_NAME'],
       :access_key_id =&gt; ENV['AWS_ACCESS_KEY_ID'],
       :secret_access_key =&gt; ENV['AWS_SECRET_ACCESS_KEY']
    }
  }
  </code></pre>