title: carrierwave multiple image upload with one button
body: <p>My question starts from <a href="https://stackoverflow.com/questions/34471165/how-to-save-dynamic-number-of-images-using-carrierwave/34471422?noredirect=1#comment56687096_34471422">here</a>.
  I'm using Sqlite3 and my model relation looks like this. </p>
  
  <pre><code>class ImagePost &lt; ActiveRecord::Base
      has_many :attachments
  end
  </code></pre>
  
  <p>My attachment</p>
  
  <pre><code>class Attachment &lt; ActiveRecord::Base
      belongs_to :image_post
      mount_uploader :img, S3uploaderUploader
  end
  </code></pre>
  
  <p>The thing is I want to make my users uploading their images with one button. Right now, I did</p>
  
  <pre><code>&lt;%= form_tag img_upload_create_path, method: "POST", html: { multipart: true } do %&gt;
          &lt;%= hidden_field_tag("image_post_id", @image_post.id ) %&gt;
          &lt;%= hidden_field_tag("user_id", current_user.id ) %&gt;
  
          &lt;%= file_field_tag 'user_pic', multiple: true, accept: 'image/png,image/gif,image/jpeg' %&gt;
  
          &lt;%= submit_tag "image-upload", :class =&gt; "btn btn-primary btn-lg" %&gt;
        &lt;% end %&gt;
  </code></pre>
  
  <p>My image_upload controller,</p>
  
  <pre><code>class ImgUploadController &lt; ApplicationController
    def create
      @user_img = Attachment.create(
          hasuk_house_id: params[:image_post_id],
          user_id: current_user.id,
          img: params[:user_pic]
          )
    end
  end
  </code></pre>
  
  <p>But when I submit files, <code>@user_img.img = nil</code> What am I going to do?</p>