title: Rails 4 - Paperclip - Dropbox production issue
body: <p>I'm using the <a href="https://github.com/thoughtbot/paperclip" rel="nofollow">Paperclip gem</a>, <a href="https://github.com/janko-m/paperclip-dropbox" rel="nofollow">paperclip-dropbox gem</a>, <a href="https://github.com/laserlemon/figaro" rel="nofollow">figaro gem</a>, and Dropbox to upload and store images when a product is created. Locally, in development, the image file is uploaded to the database fine, and is visible, but in production, where the image is supposed to go to Dropbox, the form doesn't go through, and I get a Dropbox Authentication error when looking at my Heroku logs. I've triple checked that my Dropbox security keys are all correct. I've looked through all related questions, and I can't find anything that will work.</p>
  
  <p>Here is the error from heroku:</p>
  
  <pre><code> DropboxAuthError (User is not authenticated.):
  2014-07-12T16:04:12.514637+00:00 app[web.1]:       app/controllers/products_controller.rb:31:in `block in create'
  2014-07-12T16:04:12.514638+00:00 app[web.1]:       app/controllers/products_controller.rb:30:in `create'
  2014-07-12T16:04:12.514640+00:00 app[web.1]: 
  2014-07-12T16:04:12.514642+00:00 app[web.1]: 
  2014-07-12T16:04:12.512474+00:00 app[web.1]: Completed 500 Internal Server Error in 2361ms
  </code></pre>
  
  <p><strong>Here is my products_controller #create action:</strong></p>
  
  <pre><code> # POST /products
   # POST /products.json
   def create
   @product = Product.new(product_params)
   @product.user = current_user
  
  respond_to do |format|
    if @product.save
      format.html { 
        redirect_to @product,
         notice: 'Product was successfully created.'
          }
      format.json { 
        render json: @product,
         status: :created,
          location: @product 
        }
    else
      format.html { render :new }
      format.json { 
        render json: @product.errors,
         status: :unprocessable_entity
     }
     end
   end
  end
  </code></pre>
  
  <p><strong>Here is the params at the end of products_create:</strong></p>
  
  <pre><code> private
  
   def set_product
    @product = Product.find(params[:id])
   end
  
  
   def product_params
    params.require(:product).permit(:description, :name, :permalink, :price, :file,  :user_id)
   end
  </code></pre>
  
  <p><strong>Here is my product model:</strong></p>
  
  <pre><code> class Product &lt; ActiveRecord::Base
  
   if Rails.env.development?
      has_attached_file :file
   else
      has_attached_file :file,
      :storage =&gt; :dropbox,
      :dropbox_credentials =&gt; Rails.root.join("config/dropbox.yml"),
      :path =&gt; ":style/:id_:filename"
   end
  
  
   belongs_to :user
   has_many :sales
  
   validates_numericality_of :price,
      greater_than: 49,
      message: "must be at least 50 cents"
  
   validates_attachment_content_type :file, :content_type =&gt; %w(image/jpeg image/jpg     image/png)
  
  end
  </code></pre>
  
  <p><strong>And finally here is the form for creating a new product:</strong></p>
  
  <pre><code> &lt;%= form_for(@product,:html =&gt; { :multipart =&gt; true }) do |f| %&gt;
   &lt;% if @product.errors.any? %&gt;
   &lt;div id="error_explanation"&gt;
    &lt;h2&gt;&lt;%= pluralize(@product.errors.count, "error") %&gt; prohibited this product from  being saved:&lt;/h2&gt;
  
    &lt;ul&gt;
    &lt;% @product.errors.full_messages.each do |message| %&gt;
      &lt;li&gt;&lt;%= message %&gt;&lt;/li&gt;
    &lt;% end %&gt;
    &lt;/ul&gt;
    &lt;/div&gt;
    &lt;% end %&gt;
  
    &lt;div class="field"&gt;
    &lt;%= f.label :name %&gt;&lt;br&gt;
    &lt;%= f.text_field :name %&gt;
     &lt;/div&gt;
  
    &lt;div class="field"&gt;
    &lt;%= f.label :permalink %&gt;&lt;br&gt;
    &lt;%= f.text_field :permalink %&gt;
    &lt;/div&gt;
  
    &lt;div class="field"&gt;
    &lt;%= f.label :description %&gt;&lt;br&gt;
    &lt;%= f.text_area :description %&gt;
    &lt;/div&gt;
  
    &lt;div class="field"&gt;
    &lt;%= f.label :price %&gt;&lt;br&gt;
    &lt;%= f.number_field :price %&gt;
    &lt;/div&gt;
  
    &lt;div class="field"&gt;
    &lt;%= f.label :user_id %&gt;&lt;br&gt;
    &lt;%= f.text_field :user_id %&gt;
    &lt;/div&gt;
  
    &lt;div class="field"&gt;
    &lt;%= f.label :file %&gt;&lt;br /&gt;
    &lt;%= f.file_field :file %&gt;
    &lt;/div&gt;
  
    &lt;div class="actions"&gt;
    &lt;%= f.submit %&gt;
    &lt;/div&gt;
  
    &lt;% end %&gt;
  </code></pre>