title: store images locally for development s3 for production Rails Paperclip
body: <p>I want to upload images on my local machine for development but store them on my Amazon S3 account for production.</p>
  
  <p>upload.rb</p>
  
  <pre><code>if Rails.env.development?
    has_attached_file :photo, :styles =&gt; { :thumb =&gt; '40x40#', :medium =&gt; '150x200&gt;', :large =&gt; '300x300&gt;'},
                              :convert_options =&gt; { :thumb =&gt; "-quality 92", :medium =&gt; "-quality 92", :large =&gt; "-quality 92"  },
                              :processors =&gt; [:cropper]
  else
    has_attached_file :photo, :styles =&gt; { :thumb =&gt; '40x40#', :medium =&gt; '150x200&gt;', :large =&gt; '300x300&gt;'},
                              :convert_options =&gt; { :thumb =&gt; "-quality 92", :medium =&gt; "-quality 92", :large =&gt; "-quality 92"  },
                              :storage =&gt; :s3,
                              :s3_credentials =&gt; "#{RAILS_ROOT}/config/s3.yml",
                              :path =&gt; ":attachment/:id/:style.:extension",
                              :bucket =&gt; 'birthdaywall_uploads',
                              :processors =&gt; [:cropper]
  end
  </code></pre>
  
  <p>There is some code repetition here.
  Is there a way to write this without code duplication.</p>
  
  <p>Here is the solution Thanks big time to Jordan and Andrey below:</p>
  
  <p>config/environments/development.rb</p>
  
  <pre><code>   PAPERCLIP_STORAGE_OPTS = {
       :styles =&gt; { :thumb =&gt; '40x40#', :medium =&gt; '150x200&gt;', :large =&gt; '300x300&gt;' },
       :convert_options =&gt; { :all =&gt; '-quality 92' },
       :processor       =&gt; [ :cropper ]
     }
  </code></pre>
  
  <p>config/environment/production.rb</p>
  
  <pre><code>  PAPERCLIP_STORAGE_OPTS = {
      :styles =&gt; { :thumb =&gt; '40x40#', :medium =&gt; '150x200&gt;', :large =&gt; '300x300&gt;' },
      :convert_options =&gt; { :all =&gt; '-quality 92' },
      :storage        =&gt; :s3,
      :s3_credentials =&gt; "#{RAILS_ROOT}/config/s3.yml",
      :path           =&gt; ':attachment/:id/:style.:extension',
      :bucket         =&gt; 'birthdaywall_uploads',
      :processor       =&gt; [ :cropper ]
    }
  </code></pre>