Wes Gamble
2006-Apr-01 00:29 UTC
[Rails] Many file fields w/same name don''t show up as params array
All,
I have a page where I am allowing the user to specify multiple image
files that are related to one HTML document.
I''m trying to set up my file_field correctly but am having trouble.
I''m trying to post into an array of images that belongs to a document.
I''ve tried:
<%= file_field(''document'', ''image[]'')
%>
<%= file_field(''document[]'', ''image[]'')
%>
and when I do debug(params), I never see more than one image in the
"document" hash.
My expectation was that this I could get params to have a document
element that then had one value which would be a hash of image values.
What am I doing wrong here?
===================================================
Here is my form:
<%= form_tag( { :action => ''upload_images'' },
{ :multipart => ''true'' } )%>
<TABLE>
<% for image in images do %>
<TR>
<TD>
<%= image.path.split(''/'').last[0..39] %>:
<% if ((! image.path.nil?) && (image.path.length > 40))
%>
<%= h("...") %>
<% end %>
</TD>
<TD>
<%= file_field(''document'', ''image'')
%>
</TD>
</TR>
<% end %>
</TABLE>
<P>
<%= submit_tag "Upload Images" %>
</P>
<%= end_form_tag %>
Thanks,
Wes
--
Posted via http://www.ruby-forum.com/.
