title: Rails paperclip - Attach multiple images
body: <p>I'm trying to attach with paperclip a multiple number of images to a component.
  As this tutorial
  <a href="http://www.tkalin.com/blog_posts/multiple-file-upload-with-rails-3-2-paperclip-html5-and-no-javascript" rel="nofollow">http://www.tkalin.com/blog_posts/multiple-file-upload-with-rails-3-2-paperclip-html5-and-no-javascript</a></p>
  
  <p>I have the following files:</p>
  
  <p>_form.html.erb</p>
  
  <pre><code>&lt;div class="field"&gt;
     &lt;%= file_field_tag('component_images_photo', multiple: true, name: "component[images_attributes][][photo]") %&gt;
  &lt;/div&gt; 
  &lt;div class="actions"&gt;
     &lt;%= f.submit %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>component.rb</p>
  
  <pre><code>has_many :images
  accepts_nested_attributes_for :images
  </code></pre>
  
  <p>image.rb</p>
  
  <pre><code>class Image &lt; ActiveRecord::Base
      attr_accessible :photo_file_name
  
      belongs_to :component
      has_attached_file :photo
  end
  </code></pre>
  
  <p>The image model has been created as:</p>
  
  <pre><code>rails generate model image
  </code></pre>
  
  <p>And the paperclip attachment:</p>
  
  <pre><code>rails g paperclip image photo
  </code></pre>
  
  <p>By this time I get the following error when trying to create a component:</p>
  
  <pre><code>Can't mass-assign protected attributes: image_attributes
  </code></pre>
  
  <p>Maybe should I forget something in the model and paperclip calls?</p>
  
  <p><strong>EDIT:</strong>
  Should I created the image model as:</p>
  
  <pre><code>rails generate model image component:references
  </code></pre>
  
  <p>??</p>