Forum: Ruby on Rails [TIPS] File_column plugin and multiple file uploads

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.
Hemant K. (Guest)
on 2006-04-25 16:30
(Received via mailing list)
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:

http://hemant.wordpress.com/2006/04/25/file_column...

I write this mail and [blog]post....so that Amy doesn't call me a Help
monster. :)
Steve K. (Guest)
on 2006-04-25 17:08
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:
>
> 
http://hemant.wordpress.com/2006/04/25/file_column...
>
> I write this mail and [blog]post....so that Amy doesn't call me a Help
> monster. :)
Hemant K. (Guest)
on 2006-04-25 17:20
(Received via mailing list)
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?
Hemant K. (Guest)
on 2006-04-25 17:27
(Received via mailing list)
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?
Matt W. (Guest)
on 2006-04-25 17:55
(Received via mailing list)
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
Matt W. (Guest)
on 2006-04-25 17:58
(Received via mailing list)
Whoops... Too early... I meant ":file_column :image to your images
model"
Hemant K. (Guest)
on 2006-04-25 18:07
(Received via mailing list)
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....
Steve K. (Guest)
on 2006-04-25 18:23
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?
This topic is locked and can not be replied to.