# Acts\_as\_attachment with more than 1 image per model

**URL:** <https://www.ruby-forum.com/t/acts-as-attachment-with-more-than-1-image-per-model/72280>\
**Category:** Rails\
**Created:** [October 16, 2006, 7:16am UTC](https://www.ruby-forum.com/t/acts-as-attachment-with-more-than-1-image-per-model/72280 "2006-10-16T07:16:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![George](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71e660/32.png) [@George](https://www.ruby-forum.com/u/George)\
**Post date:** [October 16, 2006, 7:16am UTC](https://www.ruby-forum.com/t/acts-as-attachment-with-more-than-1-image-per-model/72280/1 "2006-10-16T07:16:36Z")

</div>

Can I use acts\_as\_attachment with a model that has more than 1 image?

---

<div class="post-metadata">

**Author:** ![George](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71e660/32.png) [@George](https://www.ruby-forum.com/u/George)\
**Post date:** [October 16, 2006, 8:25am UTC](https://www.ruby-forum.com/t/acts-as-attachment-with-more-than-1-image-per-model/72280/2 "2006-10-16T08:25:17Z")

</div>

On 10/16/06, George [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Can I use acts\_as\_attachment with a model that has more than 1 image?

Each attachment is one image. Use a has\_many association for multiple  
attachments:

class PhotoAlbum \< AR::Base  
has\_many :photos  
end

class Photo \< AR::Base  
acts\_as\_attachment  
belongs\_to :photo\_album  
end

–  
Rick O.  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![George](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71e660/32.png) [@George](https://www.ruby-forum.com/u/George)\
**Post date:** [December 5, 2006, 7:20pm UTC](https://www.ruby-forum.com/t/acts-as-attachment-with-more-than-1-image-per-model/72280/3 "2006-12-05T19:20:18Z")

</div>

On 12/5/06, mixplate [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> hello,  
> i a form where user can submit a photo, all i need to is just create  
> another field for the 2nd, 3rd,…image? or is it only 1 image i can  
> upload per form?

You can upload as many photos as you want. Check out how Mephisto  
does it:

[http://demo.mephistoblog.com/admin/assets/new](http://demo.mephistoblog.com/admin/assets/new) (admin/admin to log in  
to the demo)

[http://svn.techno-weenie.net/projects/mephisto/trunk/app/controllers/admin/assets\_controller.rb](http://svn.techno-weenie.net/projects/mephisto/trunk/app/controllers/admin/assets_controller.rb)

–  
Rick O.  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![George](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71e660/32.png) [@George](https://www.ruby-forum.com/u/George)\
**Post date:** [December 5, 2006, 6:49pm UTC](https://www.ruby-forum.com/t/acts-as-attachment-with-more-than-1-image-per-model/72280/4 "2006-12-05T18:49:17Z")

</div>

hello,  
i a form where user can submit a photo, all i need to is just create  
another field for the 2nd, 3rd,…image? or is it only 1 image i can  
upload per form?
