# Has\_images

**URL:** <https://www.ruby-forum.com/t/has-images/78327>\
**Category:** Rails\
**Created:** [December 28, 2005, 1:49am UTC](https://www.ruby-forum.com/t/has-images/78327 "2005-12-28T01:49:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sprsquish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sprsquish](https://www.ruby-forum.com/u/sprsquish)\
**Post date:** [December 28, 2005, 1:49am UTC](https://www.ruby-forum.com/t/has-images/78327/1 "2005-12-28T01:49:33Z")

</div>

Out of curiosity: is anyone working on something like a “has\_images”  
association? As in it would be able to handle images at the model level.  
Not neccissarily hold them in a DB, but as flat files, as part of the  
filesystem.

I’m continually finding myself in need of something like this. A way of  
associating an image or a set of images to a model.

I’m starting on it now, but I need help, I really have little idea what  
I’m doing right now.

How I’m seeing it, it would act just like any other association. All  
that would go into the model itself would be something like:

has\_images :type =\> ‘jpg’, :labels =\> {:small =\> ‘10x10’, :medium =\>  
‘30x30’, :not\_quite\_large =\> ‘40x40’}, :directory =\> ‘’

:type would default to png  
:labels would be totally arbitrary, you could set as many or as few as  
you wished. none would leave the file alone and just drop it into the  
directory  
:directory is optional and would default to  
‘public/images/#{model\_name}/#{label}’

Retreval for an image tag would go something like  
model.images.small  
model.images.not\_quite\_large

As I said, I’m more than happy to be the guy hacking this out, but I  
need to talk to someone willing to explain the inner workings of model  
associations.

Thanks,  
–Jeff

---

<div class="post-metadata">

**Author:** ![sprsquish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sprsquish](https://www.ruby-forum.com/u/sprsquish)\
**Post date:** [December 28, 2005, 2:41am UTC](https://www.ruby-forum.com/t/has-images/78327/2 "2005-12-28T02:41:13Z")

</div>

[http://www.kanthak.net/opensource/file\_column/](http://www.kanthak.net/opensource/file_column/)

---

<div class="post-metadata">

**Author:** ![sprsquish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sprsquish](https://www.ruby-forum.com/u/sprsquish)\
**Post date:** [December 28, 2005, 2:46am UTC](https://www.ruby-forum.com/t/has-images/78327/3 "2005-12-28T02:46:07Z")

</div>

Craig A. wrote:

> [http://www.kanthak.net/opensource/file\_column/](http://www.kanthak.net/opensource/file_column/)

HA! beautiful! thank you
