title: Encoding::UndefinedConversionError when trying to upload an image
body: <p>I am using the following code to upload the image in /public/uploads/ folder in my root rails directory.</p>
  
  <pre><code> uploaded_io = params[:product_image]
   File.open(Rails.root.join('public','uploads', uploaded_io.original_filename), 'w') do |file|
      file.write(uploaded_io.read)
   end
  </code></pre>
  
  <p>My form looks like this </p>
  
  <pre><code>&lt;%= form_tag({:action =&gt; :configure_product}, :multipart =&gt; true) do %&gt;
  &lt;%= label_tag(:product_image, "Image:") %&gt;&lt;br /&gt;
  &lt;%= file_field_tag 'product_image' %&gt;
  &lt;%= submit_tag "Save and add another", :name =&gt; 'save and add another' %&gt;
  &lt;%= submit_tag "Save", :name =&gt; 'save' %&gt; 
  &lt;% end %&gt;
  </code></pre>
  
  <p>but when trying to submit the form I get the following error.</p>
  
  <p>Encoding::UndefinedConversionError in ConfigureCategoryController#configure_product</p>
  
  <p>"\xFF" from ASCII-8BIT to UTF-8</p>
  
  <p>I replaced the writing mode from 'w' to 'wb' and now I am getting</p>
  
  <p>NoMethodError in ConfigureCategoryController#configure_product</p>
  
  <p>undefined method `name' for nil:NilClass</p>
  
  <p>New at rails. Would surely appreciate the help.</p>