title: Rails 4 - Creating a folder inside public, to store uploaded files
body: <p>This is the sample in the documentation for Rails, when saving uploaded files.</p>
  
  <pre><code>def upload
    uploaded_io = params[:person][:picture]
    File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'wb') do |file|
      file.write(uploaded_io.read)
    end
  end
  </code></pre>
  
  <p>This works alright, but what if I wanted to create a unique folder, for every upload made?</p>
  
  <pre><code>def upload
  
    // How to add this to the path of the saved file??
    uid = Digest::SHA1.hexdigest([Time.now, rand].join)
  
  
    uploaded_io = params[:person][:picture]
    File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'wb') do |file|
      file.write(uploaded_io.read)
    end
  
  
  end
  </code></pre>