Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="https://github.com/blueimp/jQuery-File-Upload/blob/master/js/jquery.fileupload.js#L140">https://github.com/blueimp/jQuery-File-Upload/blob/master/js/jquery.fileupload.js#L140</a></p> <p>The file upload plugin submits the form via Ajax (creating the post) as soon as you select the file (see linked file for source). This will create your objects as soon as they select it.</p> <p>Why do you need the fileupload plugin? You don't need to submit them via AJAX, so just nested form should be able to solve your problems. Just use link_to_add and link_to_remove with a regular filefield.</p> <p>EDIT:</p> <p>Assuming you want to keep the file field plugin (which it seems you do), then you need to have a way of recieving them.</p> <p>The best way to do this, is inside the posts view page, have the file upload code nested inside a form for your Photos, <em>not</em> inside a nested form for your Post. This way, every photo will post to a photo-create option, and then you can provide a javascript call-back in the photos controller that updates the Post form with a hidden field, telling it which photo_ids were uploaded to this post(and obviously secure this!).</p> <p>I personally don't like this approach, because you will be uploading and accepting the files <em>before</em> the user creates the post form (meaning they can just navigate away and leave you with 5-10 photos on your server not tied to any post)...but it is a necessary pre-condition if you want them to be able to upload the photos using the AJAX (aka, file upload plugin). </p> <p>There isn't a super nice way of doing this, file upload work is usually messy. I don't know of any jQuery plugins that work on a file field and allow you to convert a multiple file-field input set into hidden fields containing each individual file. </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