"it's absolutely necessary in order to support more than one
attachment on a class" is a matter of opinion. I am a firm believer in
not class-scoping column names unless absolutely vital, instead I'm a
proponent of keeping things abstracted. By that I mean for instance,
if a user can have a photo, I'd rather the photos be their own model
and table. In agile methods, this is the most practical way of
achieving the goal, since it makes photos mostly independent of a user
and able to belong to multiple models. If you decide you don't want
your users to have photos anymore, you just delete the photos table.
This practice would be standard for many things, not just
attachments... user can have a group, but you more than likely
wouldn't put a group_id foreign key on your user model. You would be
wise to create a join table. Then when you don't want groups anymore
delete the groups table, or when something about the association
between a user and a group changes, your join model handles it, not
your user model. I agree that attachment_fu and paperclip are not the
same thing, I've already come to that conclusion hours ago.
In my opinion, an attachment is an object, and to tie it so closely to
another model is not useful in my case, and I can probably come up
with a thousand cases where it is or isn't useful depending on
context. I'm not saying paperclip is wrong or bad by any means, just
that it seems to have been developed with the intent of keeping it
very tightly coupled with it's "attached" class is all -- it becomes
an attribute instead of an association. So, I've decided to stick w/
attachment_fu on this particular project since, in my opinion, my
class objects (video/photo/etc) ARE the attachments and my aim was to
keep it that way.
Another reason, which your point validates the negative of, is... what
if I have a business rule that says, show me all user photos? What
you're suggesting means that I have to fetch every user record and
then iterate over them grabbing the photo off each one. No thanks. My
project requires viewing lists of the different types of attachments,
regardless of the class that "owns" them -- it would be a severe pain
if I had to grab all the records for the several different classes
that can even have attachments, and then start figuring out, which
have videos vs. which have photos vs. which have documents, etc. With
my way, I can just say Video.all and it doesn't matter if the video
belongs to a news article, a group, a user, or an event, doing this
means I will have tons of video objects, of which I can manipulate as
attachments.
~ Jen