# OT: form and multiple pics......pic included!

**URL:** <https://www.ruby-forum.com/t/ot-form-and-multiple-pics-pic-included/71378>\
**Category:** Rails\
**Created:** [October 8, 2006, 12:59am UTC](https://www.ruby-forum.com/t/ot-form-and-multiple-pics-pic-included/71378 "2006-10-08T00:59:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [October 8, 2006, 12:59am UTC](https://www.ruby-forum.com/t/ot-form-and-multiple-pics-pic-included/71378/1 "2006-10-08T00:59:49Z")

</div>

hi,  
i am creating a form for a recipe site and would like to make it as  
simple as possible. ive done some researching all day today and it seems  
that trying to upload multiple files on 1 form using ajax may not be the  
best solution if i want to keep eveything simple and maintanable. if you  
look at the attachment, i had a vision where the user would upload a  
photo, the code would then return a thumbnail next to the photo that was  
just uploaded, and bump the upload photo option down by one, so the user  
can upload additional photos.

the problem with this is that the user has not submitted the recipe yet.  
but i guess i can get around this by associating each uploaded photo  
with a form recipe ID. but if the user decides to cancel the recipe, i  
may need to add a cleanup for the photo that was uploaded? would this be  
worth pursueing, or maybe it would just be easier that in each user  
account, i can just give the user a gallery section where they can  
upload photos one by one under each recipe?. what would be the best  
solution for this?

---

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [October 8, 2006, 1:01am UTC](https://www.ruby-forum.com/t/ot-form-and-multiple-pics-pic-included/71378/2 "2006-10-08T01:01:31Z")

</div>

> **[ImageShack - Best place for all of your image hosting and image sharing needs](https://imageshack.com/)**
>
> Unlimited space to host images, easy to use image uploader, albums, photo hosting, sharing, dynamic image resizing on web and mobile.

---

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [October 8, 2006, 7:41am UTC](https://www.ruby-forum.com/t/ot-form-and-multiple-pics-pic-included/71378/3 "2006-10-08T07:41:39Z")

</div>

Hi…

koloa wrote:

> upload photos one by one under each recipe?. what would be the best  
> solution for this?

I prefer to save the main record first and then get the user to upload  
the pictures one by one. What you showed in the picture you posted to  
the list will also work. IMO, this is a good design if the user _must_  
submit at least one picture. Your style makes it easy to add that.

On the other hand, if I allow them to upload multiple pictures, I would  
usually get the main record in first. Then, when I display the main  
recipe, I would give them links to: [Edit this record] | [Add pictures]  
… and so on. The link to add pictures would include the parent ID  
that would be stored in a hidden field and posted back from the form  
that allowed them to upload the picture.

Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [October 8, 2006, 2:24pm UTC](https://www.ruby-forum.com/t/ot-form-and-multiple-pics-pic-included/71378/4 "2006-10-08T14:24:47Z")

</div>

hi mohit,  
thanks for the reply. that sounds like a good idea and it would also  
make things much easier to maintain and implement. acts\_as\_attachment is  
a cool plugin. i will modify that + the logingenrator and walaa, i  
should have that capability.

---

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [October 8, 2006, 4:10pm UTC](https://www.ruby-forum.com/t/ot-form-and-multiple-pics-pic-included/71378/5 "2006-10-08T16:10:23Z")

</div>

koloa wrote:

> hi mohit,  
> thanks for the reply. that sounds like a good idea and it would also  
> make things much easier to maintain and implement. acts\_as\_attachment is  
> a cool plugin. i will modify that + the logingenrator and walaa, i  
> should have that capability.

You are most welcome. Just to let you know, I did the implementation  
using FileColumn instead of acts\_as\_attachment and saved images to the  
file system. That said, I stored the pictures outside of a public  
directory so that they could not be accessed by users who were not  
logged in. My understanding is that you will probably not need to  
‘protect’ the images if in real fact, they actually are pictures of food  
items (and recipes was not your way of simplifying the idea for us to  
respond).

Anyway, if you do need to protect the images, store them to a different  
directory (i.e., outside your public directory) and have a controller  
action that uses send\_file to actually stream the file to the browser.

Cheers  
Mohit.
