title: rails, carrierwave, multiple images
body: <p>I am working on my first rails application and I am attempting to setup multiple image uploads in a form. I have created a contest which has many contest entries, and contest entries can have many images. I have the contest entry piece working, but I am having trouble getting the image upload portion of the form working. I am following this tutorial <a href="http://lucapette.com/rails/multiple-files-upload-with-carrierwave-and-nested_form/" rel="nofollow">http://lucapette.com/rails/multiple-files-upload-with-carrierwave-and-nested_form/</a> linked to from the carrier wave wiki. </p>
  
  <p>contest entry model </p>
  
  <pre><code>class ContestEntry &lt; ActiveRecord::Base
    attr_accessible :body, :title, :contest_id, :entry_images_attributes
    validates :user_id, presence: true
    validates :title, presence: true, length: { maximum: 140 }
    validates :body, presence: true
    validates :contest_id, presence: true
  
    belongs_to :contest
    belongs_to :user
  
    has_many :entry_images, as: :imageable
  
    accepts_nested_attributes_for :entry_images
  end
  </code></pre>
  
  <p>Entry image model</p>
  
  <pre><code>class EntryImage &lt; ActiveRecord::Base
    attr_accessible :alt, :image_path
  
    belongs_to :imageable, :polymorphic =&gt; true
  
    validates :image_path, presence: true
  
    mount_uploader :image, ImageUploader
  end
  </code></pre>
  
  <p>New entry form</p>
  
  <pre><code>&lt;%= nested_form_for([:contest, @entry], :html =&gt; {:multipart =&gt; true}) do |f| %&gt;
      &lt;%= render 'shared/error_messages', object: f.object %&gt;
      &lt;%= f.hidden_field :contest_id %&gt;
      &lt;p&gt;
          &lt;%= f.label :title %&gt;&lt;br /&gt;
          &lt;%= f.text_field :title %&gt;
      &lt;/p&gt;
  
      &lt;p&gt;
          &lt;%= f.label :body %&gt;&lt;br&gt;
          &lt;%= f.text_area :body %&gt;
      &lt;/p&gt;
  
      &lt;%= f.fields_for :entry_images do |builder|  %&gt;
          &lt;p&gt;
          &lt;%= builder.label :alt %&gt;&lt;br /&gt;
          &lt;%= builder.text_field :alt %&gt;
          &lt;/p&gt;
          &lt;p&gt;
          &lt;%= builder.label :image_path %&gt;&lt;br /&gt;
          &lt;%= builder.file_field :image_path %&gt;
          &lt;/p&gt;
  
      &lt;% end %&gt;
      &lt;p&gt;&lt;%= f.link_to_add "Add Image", :entry_images %&gt;&lt;/p&gt;
  
      &lt;%= f.submit "Enter", class: "btn btn-large btn-primary" %&gt;
  &lt;% end %&gt;
  &lt;%= javascript_include_tag :defaults,"nested_form" %&gt;
  </code></pre>
  
  <p>for some reason nothing shows up in the &lt;%= f.fields_for :entry_images do |builder|  %> block. It is just blank there is also no error message. if I switch it to 
  &lt;%= f.fields_for :entry_image do |builder|  %> and switch to using a form_for instead of the nested_form_for plugin all the fields show up but I get errors when I submit.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks,
  Cory</p>