0
votes

I am using jQuery File Upload together with Carrierwave for uploading images.

I managed to make it working by following this manual and it works perfectly well for uploading single images, but once I add HTML5 multiple attribute to allow uploading multiple images at once and select multiple images, I get following error on each request.

NoMethodError in Advertiser::MediaController#create
undefined method `[]' for nil:NilClass

Every request seems absolutely same to me and I can't seem to figure out why it can't upload multiple images but can upload single images, please note that if I have multiple attribute enabled, I can't even upload a single image but once I take it off, uploading works once again. jQuery File Upload is perfectly capable of uploading multiple images and you can check it out in their demo.

Any hints on where to dig would be very much appreciated.

Thank you in advance.

1

1 Answers

1
votes
  def create_from_uploader
    p_attr = params[:photo]
    p_attr[:photo] = p_attr[:photo][0] if p_attr[:photo].is_a?(Array)
    @photo = @user.photos.build(p_attr)
    if @photo.save
      flash[:notice] = "Succes"
    end
  end

And in your haml view html options for form like this - html: {multipart: true}, and for file_field use multiple: true