title: Setting URL/PATH correctly for AWS S3 by using Paperclip/Rails
body: <p>I have two models: <code>Collection</code> and <code>Letter</code>. <code>Collection</code> has many <code>Letter</code>s and <code>Letter</code> obviously belongs_to <code>Collection</code>.</p>
  
  <p>Below is my Letter.rb file:</p>
  
  <pre><code>class Letter &lt; ActiveRecord::Base
      belongs_to :collection
  
      has_attached_file :pdf,
                      :url =&gt; "/pdf/:id/:style/:basename.:extension",
                      :path =&gt; "/pdf/:id/:style/:basename.:extension",
                      :s3_host_name =&gt; host_name,
                      :storage =&gt; :s3,
                      :bucket  =&gt; ENV['S3_BUCKET_NAME'],
                      :s3_credentials =&gt; {
                                          :access_key_id =&gt;#ENV['AWS_ACCESS_KEY_ID'],
                                          :secret_access_key =&gt;ENV['AWS_SECRET_ACCESS_KEY']
                                      }
  
      validates_attachment :pdf,
                       :content_type =&gt; {
                           :content_type =&gt;
                               ["application/pdf", "text/plain", /\Aimage\/.*\Z/, "application/msword"]
                       }
  
  end
  </code></pre>
  
  <p>I have a question about <code>url</code> and <code>path</code> attribute in <code>has_attached_file</code>.</p>
  
  <p>Instead of setting letter model's id in path, I would like to set collection's id. Additionally, I also wanna put <code>title</code> which is Letter's attribute. Let's say <code>@collection</code>'s id is 1. <code>@collection</code> has @letter1 and @letter2. When I save the files to AWS S3, I want to save it under <code>/pdf/1(which is collection_id)/:title</code>. How can I write this in <code>url</code> and <code>path</code>?</p>