Lots of requests but not many answers on this topic. Here is how you do
it:
FORM:
<table>
<% for i in 1..6 %>
<tr>
<td
class=''Label''><label>Title</label></td>
<td><input id="<%= "picture_#{i}_title"
%>" name="<%"picture[#{i}][title]" %>"
size="30" type="text" /></td>
</tr>
<tr>
<td class=''Label''><label
for="image_data">Image</label></td>
<td><input id="<%= "picture_#{i}_image_data_temp"
%>" name="<%"picture[#{i}][image_data_temp]"
%>" type="hidden" />
<input id="<%= "picture_#{i}_image_data"
%>" name="<%"picture[#{i}][image_data]" %>"
size="30" type="file" /></td>
</tr>
<tr>
<td><br /></td>
</tr>
<% end %>
</table>
CONTROLLER:
params[:picture].each { |attr, value|
unless value[:image_data].blank?
new_image = Image.new
new_image.person_id = session[:person_id]
new_image.title = value[:title]
new_image.image = value[:image_data]
new_image.save
end
}
MODEL:
class Image < ActiveRecord::Base
file_column :image
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Taylor Strait schrieb:> Lots of requests but not many answers on this topic. Here is how you do > it: > > FORM: > <table> > <% for i in 1..6 %> > <tr> > <td class=''Label''><label>Title</label></td> > <td><input id="<%= "picture_#{i}_title" %>" name="<%> "picture[#{i}][title]" %>" size="30" type="text" /></td> > </tr> > <tr> > <td class=''Label''><label for="image_data">Image</label></td> > <td><input id="<%= "picture_#{i}_image_data_temp" %>" name="<%> "picture[#{i}][image_data_temp]" %>" type="hidden" /> > <input id="<%= "picture_#{i}_image_data" %>" name="<%> "picture[#{i}][image_data]" %>" size="30" type="file" /></td> > </tr> > <tr> > <td><br /></td> > </tr> > <% end %> > </table> > > > CONTROLLER: > params[:picture].each { |attr, value| > unless value[:image_data].blank? > new_image = Image.new > new_image.person_id = session[:person_id] > new_image.title = value[:title] > new_image.image = value[:image_data] > new_image.save > end > } > > > MODEL: > class Image < ActiveRecord::Base > > file_column :image > > end > >Hi Taylor, how do you handle and display the errormessages, e.g: the 1st and 3rd file don“t match filesize or filetype etc out of a total of 4 ?? Best regards matthi ps: i have also multiple_file upload running, even my code is different, the error_message_stuff should/could be handled the same --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Maybe Matching Threads
- Accessing model attributes in ActiveSupport::Concern module
- problem starting domains
- libswfdec/swfdec_image.c libswfdec/swfdec_image.h libswfdec/swfdec_pattern.c
- Branch 'interpreter' - 18 commits - libswfdec/swfdec_image.c libswfdec/swfdec_image.h libswfdec/swfdec_js.c libswfdec/swfdec_js_color.c libswfdec/swfdec_js_sound.c libswfdec/swfdec_pattern.c libswfdec/swfdec_scriptable.c libswfdec/swfdec_script.c
- rmagick and captcha