[TIPS] File_column plugin and multiple file uploads

No…i am not a full time rails developer…i code in pl/sql for paying
my
bills…and i am just working on a pet project…so i had some trouble
in
doing…what i specify in the subject…now somehow i solved this
problem…so those interested can look at the code at:

I write this mail and [blog]post…so that Amy doesn’t call me a Help
monster. :slight_smile:

I read your blog post. You seem to be complicating things. It is
perfectly valid to have multiple fields in the same table use
file_column.

Why not just say in your model

file_column :picture_1
file_column :picture_2

and then simply let file_column work like it’s supposed to, complete
with file_column_field helpers?

hemant kumar wrote:

No…i am not a full time rails developer…i code in pl/sql for paying
my
bills…and i am just working on a pet project…so i had some trouble
in
doing…what i specify in the subject…now somehow i solved this
problem…so those interested can look at the code at:

file_column and how the fuck it handles multiple files? | Oh Lame saint

I write this mail and [blog]post…so that Amy doesn’t call me a Help
monster. :slight_smile:

But then i thought in “file_column :picture”, picture must be a column
in
the table, right?
and i have only one column to store filenames in my table…correct me,
if
i am wrong?

Also is it a good idea to predefine, the number of files that i can
upload?..though my current code relies on that…but i am gonna change
that…and if in the model class itself i specify how many columns i
need
then i am stuck there, right?

If I have a model that requires a variable # of images, I usually just
create an additional table called model_images, and then add a :has_many
=>
:model_images (with a corresponding belongs_to :model in the images
model)
to my model. That way if you need to have metadata about the images
(captions, or whatever), you can store that in the images table. This
way
your # of images is unlimited, and you can just add a :file_column
:image or
whatever to your images table.

Works for me…

Matt

Whoops… Too early… I meant “:file_column :image to your images
model”

yeah…got it…thatz a cool idea…but right now basically pictures
table
is like your model_images table…and i am storing all the metadata,
like Tags and all that in this table itself…

Yes, you would need a varchar/:string column in your table for each
file_column.

Sorry, your action name and the post titles confused me. This looks like
a method just for adding multiple new image records from a single form.

I gather that mutliple instances of

<%= file_column_field "picture[], “filename” -%>

in a single form doesn’t work, eh?

hemant kumar wrote:

But then i thought in “file_column :picture”, picture must be a column
in
the table, right?
and i have only one column to store filenames in my table…correct me,
if
i am wrong?