Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Dave Lehman's Profile

GitHub User: dlehman

Comments by Dave Lehman

Avatar

I had the same perennial desire to be able to add images to a gallery without having to save it first.

I found a sample app demo of jquery-file-upload using carrierwave on GitHub that did almost what I wanted. I added the ability to be able to add images before the gallery record had been saved.

I generated a unique token (GUID) when a "New Gallery" form is displayed. This token is saved with each image as it's uploaded and saved as an independent "Picture" record. When the gallery is finally saved, it finds any Picture records with the matching token, and adds them as children.

Note: if you upload images, but abandon the form before saving it, you do get orphaned pictures. You would need to clean these up periodically.

https://github.com/dlehman/Rails-Carrierwave-jQuery-File-Upload