Advice about upload form

I have Article model that has_many images.

The edit page for an article has two different forms, one for the
article itself and another for uploading images. The upload-form
uploads an image and redirects to the edit page. I did this to make it
easy to make links to images in the text of the article.

The problem of this design is when a user enters some info in the
article form and doesn’t submit the form, if the user subsequently
uploads an images the entered info gets lost.

I’ve thought of a couple of solutions to this problem:

Upload the images via AJAX

Uploading via AJAX is not really possible but there are some
workarounds with hidden iFrames. This feels a bit hackish, but it
might be the best solution.

Also send the article form when uploading

When uploading a file I could also send the article form to the upload
action. I could then make a new @article object (without saving it)
and use that to repopulate the form after the redirect. Problem is, I
have no idea to send the fields/values from one form together with an
other form and I can’t find anything about doing this.

Could somebody give me some tips? Maybe I’m going about this all
wrong, I feel I’m overlooking a simple solution.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs