On 12/12/05, chongqing xiao
<cqxiao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I have a Photo table like this
>
> id
> image_url
> title
>
> I hope I can use file_column to load image. The problem is file_column only
> supports one file. I know I can create multi columns in the table to
> load multi files using
> file_column but I only want one column and I want the files being
> uploaded to save into different record instead of one photo record.
how about just having a Photo model with one file_column and simply
storing several of them? If you have several file uploads field in
your view like this:
<%= file_column "photo1", "image" %>
<%= file_column "photo2", "image" %>
...
and in your controller that saves the form:
@photo1 = Photo.new(params[:photo1])
@photo1.save
@photo2 = Photo.new(params[:photo2])
@photo2.save
...
There should be a more elegant way with rails auto-numbering the
fields, but I''m too lazy to figure this out. Of course, you could loop
to avoid violating DRY etc. but this should give you an idea.
Sebastian