Forum: Ruby on Rails has_images

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9046f1681dc8375fd81b34799d5abd36?d=identicon&s=25 Jeff Smick (sprsquish)
on 2005-12-28 01:49
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
8a456610e31c8feadc4cef71d9347cbd?d=identicon&s=25 Craig Ambrose (Guest)
on 2005-12-28 02:41
(Received via mailing list)
9046f1681dc8375fd81b34799d5abd36?d=identicon&s=25 Jeff Smick (sprsquish)
on 2005-12-28 02:46
Craig Ambrose wrote:
> http://www.kanthak.net/opensource/file_column/

HA! beautiful! thank you
This topic is locked and can not be replied to.