Note that there are some explanatory texts on larger screens.

plurals
  1. PORails3, S3, Paperclip Attachment as it's own model?
    primarykey
    data
    text
    <p>So, I'm working on an app where users can upload and manage photos with a bunch of industry specific metadata attached to them.</p> <p>The Photo model has all this metadata in it, and I'm using Paperclip to attach the actual image file to the model and store the images on Amazon S3.</p> <p>The user interaction currently works like this:</p> <ol> <li>A user clicks "Add Photo" and is taken to the "New Photo" page where he is presented a form.</li> <li>The first thing on the form is a file chooser. The user selects a file.</li> <li>Beneath this are several different fields of metadata for the user to fill out, so the user fills these out.</li> <li>The user hits submit, the file uploads and a new Photo object is created, the user is redirected to a different page.</li> </ol> <p>So, the obvious improvement that I'd like to make is for the photo to actually upload at the beginning of this process so that there isn't such a noticeable delay between hitting submit and being redirected to the next page. It would also be nice to be able to show the user a thumbnail preview of their photo once it's done uploading, so that they can see the photo they're putting in metadata about as they fill in the form.</p> <p>I figure I could make that happen if I split the image file into its own model, but I'd then be referring to the images like so:</p> <p><code>@photo.attachment.file.url</code> instead of the simpler <code>@photo.file.url</code> that I use now. I'd rather not "nest it" more deeply than I have to.</p> <p>Also, splitting it into two models raises the issue of managing orphans, which I currently don't have to deal with.</p> <p>So my questions are:</p> <ol> <li>Is there a good way - preferably <em>not</em> using Flash - to create this asynchronous upload behavior without splitting into two models, OR --</li> <li>If I <em>must</em> split the metadata and the file into two models, is there a way to get Paperclip to treat an attachment as its own model so that I can access it using <code>&lt;modelname&gt;.&lt;paperclip_method&gt;</code> instead of <code>&lt;model_name&gt;.&lt;attachment_attribute&gt;.&lt;paperclip_method&gt;</code>?</li> </ol> <p>I know that's a big question, so thank you very much in advance for your help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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