Note that there are some explanatory texts on larger screens.

plurals
  1. POCarrierwave upload with nested forms?
    text
    copied!<p>Not sure what's going on here, but I think my nested form partials are causing a problem for CarrierWave.</p> <p>When I update a field with an uploaded file, nothing happens: no error, but nothing stored either.</p> <p>I have a "Household" model with a "has_many" relationship with an "Individuals" model. The "Individuals" model has a "picture" uploader:</p> <pre><code>class Individual &lt; ActiveRecord::Base belongs_to :household mount_uploader :picture, PictureUploader end </code></pre> <p>In my views I have:</p> <pre><code>= form_for @household, :html =&gt; {:multipart =&gt; true} do |f| </code></pre> <p>and then call a partial for the individuals:</p> <pre><code>= f.fields_for :individuals do |builder| = render 'individual_fields', :f =&gt; builder = f.submit </code></pre> <p>The partial just has the following:</p> <pre><code>= f.label :firstname, 'First' = f.text_field :firstname, :size =&gt; 10 = f.label :lastname, 'Last' = f.text_field :lastname, :size =&gt; 15 = f.file_field :picture </code></pre> <p>The uploaded picture appears in the params:</p> <pre><code>Started POST "/households/849" for 127.0.0.1 at 2011-02-15 15:45:16 -0500 Processing by HouseholdsController#update as HTML Parameters: {"...6/1/2008; Active 6/6", "individuals_attributes"=&gt;{"0"=&gt;{"firstname"=&gt;"Hannah", ... "picture"=&gt;#&lt;ActionDispatch::Http::UploadedFile:0xb9fbd24 @original_filename="3.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"household[individuals_attributes][1][picture]\"; filename=\"3.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#&lt;File:/tmp/RackMultipart20110215-6498-ba4bp&gt;&gt;, "_destroy"=&gt;"false", "id"=&gt;"4077"}}}, "commit"=&gt;"Update Household", "id"=&gt;"849"} </code></pre> <p>And is stored in the tmp directory under the upload path. It's just never saved to the database, nor moved into place in the filesystem.</p> <p>Any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload