I\'m close...very close...I\'m able to upload single files just fine...but when i change the type of my form\'s file_field
to :multiple => true
You can do a little hack for the params array, something like:
aux = []
params[:gallery][:photos_attributes][:image].each do |f|
aux << {:image => f}
end
params[:post][:photos_attributes] = aux
@gallery = Gallery.new(params[:gallery])
I have a similar problem, I know it's an ugly hack, but it works for me.
Ditch accepts_nested_attributes_for and instead add this to your Gallery model.
def photos=(attrs)
attrs.each { |attr| self.photos.build(:image => attr) }
end
Also, make sure that photos is in your gallery's accessible attribs in case you're protecting against mass assignment. Otherwise you won't get the photos array hash assignment from your params. I.e.
attr_accessible :field1, field2, :photos