Topic: Handling attachments
I have a rails app that uses polymorphic attachments for several objects. Currently I'm using nested forms to create uploads when editing the parent object.
This works as it should, but I stumbled upon blog post describing new HTML5 drag&drop uploading as it's already known from the Gmail webinterface, for example.
I'd like to offer such a functionality aswell, but I have some questions about the actual saving of uploaded items.
Usually you have a form and select some files (images in my case) and then you submit which starts the actual upload. The parent object gets saved first and then the ID will be put in the attachment records asuming a model like this:
has_many :attachments, :as => :attachable, :class_name => "Upload", :dependent => :destroy
Now this won't work with drag&drop uploading, because the file upload happens right after selecting the file and the parent object doesn't yet exist.