C'est une solution pour télécharger plusieurs images à l'aide de carrierwave dans les rails 4 à partir de zéro
  
  Ou vous pouvez trouver une démo de travail:
   Rails de fixation multiples 4
Pour ce faire, suivez simplement ces étapes.
rails new multiple_image_upload_carrierwave
Dans le fichier gem
gem 'carrierwave'
bundle install
rails generate uploader Avatar 
Créer un échafaudage de poste
rails generate scaffold post title:string
Créer un échafaudage post_attachment
rails generate scaffold post_attachment post_id:integer avatar:string
rake db:migrate
Dans post.rb
class Post < ActiveRecord::Base
   has_many :post_attachments
   accepts_nested_attributes_for :post_attachments
end
Dans post_attachment.rb
class PostAttachment < ActiveRecord::Base
   mount_uploader :avatar, AvatarUploader
   belongs_to :post
end
Dans post_controller.rb
def show
   @post_attachments = @post.post_attachments.all
end
def new
   @post = Post.new
   @post_attachment = @post.post_attachments.build
end
def create
   @post = Post.new(post_params)
   respond_to do |format|
     if @post.save
       params[:post_attachments]['avatar'].each do |a|
          @post_attachment = @post.post_attachments.create!(:avatar => a)
       end
       format.html { redirect_to @post, notice: 'Post was successfully created.' }
     else
       format.html { render action: 'new' }
     end
   end
 end
 private
   def post_params
      params.require(:post).permit(:title, post_attachments_attributes: [:id, :post_id, :avatar])
   end
Dans views / posts / _form.html.erb
<%= form_for(@post, :html => { :multipart => true }) do |f| %>
   <div class="field">
     <%= f.label :title %><br>
     <%= f.text_field :title %>
   </div>
   <%= f.fields_for :post_attachments do |p| %>
     <div class="field">
       <%= p.label :avatar %><br>
       <%= p.file_field :avatar, :multiple => true, name: "post_attachments[avatar][]" %>
     </div>
   <% end %>
   <div class="actions">
     <%= f.submit %>
   </div>
<% end %>
Pour modifier une pièce jointe et une liste de pièces jointes pour n'importe quel message.
Dans views / posts / show.html.erb
<p id="notice"><%= notice %></p>
<p>
  <strong>Title:</strong>
  <%= @post.title %>
</p>
<% @post_attachments.each do |p| %>
  <%= image_tag p.avatar_url %>
  <%= link_to "Edit Attachment", edit_post_attachment_path(p) %>
<% end %>
<%= link_to 'Edit', edit_post_path(@post) %> |
<%= link_to 'Back', posts_path %>
Mettre à jour le formulaire pour modifier une pièce jointe views / post_attachments / _form.html.erb
<%= image_tag @post_attachment.avatar %>
<%= form_for(@post_attachment) do |f| %>
  <div class="field">
    <%= f.label :avatar %><br>
    <%= f.file_field :avatar %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>
Modifier la méthode de mise à jour dans post_attachment_controller.rb
def update
  respond_to do |format|
    if @post_attachment.update(post_attachment_params)
      format.html { redirect_to @post_attachment.post, notice: 'Post attachment was successfully updated.' }
    end 
  end
end
Dans les rails 3, il n'est pas nécessaire de définir des paramètres forts et comme vous pouvez définir attribute_accessible à la fois dans le modèle et accept_nested_attribute pour poster le modèle car l'attribut accessible est déconseillé dans les rails 4.
Pour modifier une pièce jointe, nous ne pouvons pas modifier toutes les pièces jointes à la fois. nous allons donc remplacer la pièce jointe une par une, ou vous pouvez la modifier selon votre règle, ici je vous montre simplement comment mettre à jour une pièce jointe.