title: Rails4: How do I store images uploaded by carrierwave in private folder?
body: <p>I have uploaded images with carrierwave under the public folder.
  For security reason, I'm going to change the folder to under the root.</p>
  
  <p>Althogh I referred to the post <a href="https://github.com/carrierwaveuploader/carrierwave/wiki/How-To%3A-Secure-Upload" rel="nofollow">How to: Secure Upload</a> and created carrierwave.rb, I don't know how to write the path uploaded by carrierwave.</p>
  
  <p>How can I display images under private folder?</p>
  
  <p>image_uploader.rb</p>
  
  <pre><code>class ImageUploaader &lt; CarrierWave::Uploader::Base
  
    storage :file
    def store_dir
      "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
    end
  
  end
  </code></pre>
  
  <p>I created \config\initializers\carrierwave.rb</p>
  
  <pre><code>CarrierWave.configure do |config|
    config.permissions = 0600
    config.directory_permissions = 0700
    config.root = Rails.root
  end
  </code></pre>
  
  <p>I also created images_controller.rb</p>
  
  <pre><code>class ImagesController &lt; ApplicationController
      #I tried some, but doesn't work
  end
  </code></pre>
  
  <p>I have used the following view to display images.<br>
  \views\articles\ _article.html.erb</p>
  
  <pre><code>&lt;% article.photos.each do |photo| %&gt;
    &lt;%= image_tag(photo.image_url(:thumb).to_s, class: :thumb) if photo.image? %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>It would be appreciated if you could specify the code in <code>routes.rb</code>, <code>images_controller.rb</code> and <code>_article.html.erb</code>.</p>