title: Nested form using paperclip
body: <p>I have a model called posts, and it has many attachments.</p>
  
  <p>The attachments model is using paperclip.</p>
  
  <p>I made a standalone model for creating attachments which works just fine, this is the view as instructed here (https://github.com/thoughtbot/paperclip):</p>
  
  <pre><code>&lt;% form_for :attachment, @attachment, :url =&gt; @attachment, :html =&gt; { :multipart =&gt; true } do |form| %&gt;
    &lt;%= form.file_field :pclip %&gt;
  
    &lt;%= form.submit %&gt;
  
  &lt;% end %&gt;
  </code></pre>
  
  <p>The nested form in posts looks like this:</p>
  
  <pre><code>&lt;% @attachment = @posts.attachments.build %&gt;
  &lt;%= form_for(@posts) do |f| %&gt;
    &lt;% if @posts.errors.any? %&gt;
      &lt;div id="error_explanation"&gt;
        &lt;h2&gt;&lt;%= pluralize(@posts.errors.count, "error") %&gt; prohibited this post from being saved:&lt;/h2&gt;
  
        &lt;ul&gt;
        &lt;% @posts.errors.full_messages.each do |msg| %&gt;
          &lt;li&gt;&lt;%= msg %&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 :description %&gt;&lt;br /&gt;
      &lt;%= f.text_area :description %&gt;
    &lt;/div&gt;
    &lt;div class="field"&gt;
      &lt;%= f.fields_for :attachments, @attachment, :url =&gt; @attachment, :html =&gt; { :multipart =&gt; true } do |at_form| %&gt;
  
        &lt;%= at_form.file_field :pclip %&gt;
  
      &lt;% end %&gt;
    &lt;/div&gt;
  
    &lt;div class="actions"&gt;
      &lt;%= f.submit %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>An attachment record is created, but its empty. The file is not uploaded. The post meanwhile, is successfully created...</p>
  
  <p>Any ideas?</p>