title: rails paperclip image upload Encoding::UndefinedConversionError ("\xFF" from ASCII-8BIT to UTF-8):
body: <p>I have used paperclip for image storage and when I try to upload and save the image, image it getting saved but I am getting <code>Encoding::UndefinedConversionError</code> while redirecting to other page.</p>
  
  <p>I tried to remove the paperclip code and do the same with normal file upload mechanism, but result is the same.</p>
  
  <pre><code>Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"janP4YndP+9xORuxP5BkEuRFpVZi7GvLcs3u+6RsSfs=", "user"=&gt;{"profile_picture"=&gt;#ActionDispatch::Http::UploadedFile:0x3622916a @original_filename="36.jpg", @headers="Content-Disposition: form-data; name=\"user[profile_picture]\"; filename=\"36.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#&lt;Tempfile:/home/ROOT/RackMultipart.13883.61589&gt;, @content_type="image/jpeg"&gt;}}
  
  
  Command :: file -b --mime 
   '/home/ROOT/36130617-13883-1gqm197-61590130617-13883-1uub191-61593'
  (1.0ms)  UPDATE `users` SET `avatar_file_name` = '36.jpg', `avatar_file_size` = 107409, `avatar_updated_at` = '2013-06-17 13:44:04', `updated_at` = '2013-06-17 13:44:04' WHERE `users`.`id` = 10
   [paperclip] deleting /home/ROOT/public/system/users/avatars/000/000/010/original/123.jpg
   [paperclip] deleting /home/ROOT/public/system/users/avatars/000/000/010/medium/123.jpg
   [paperclip] deleting /home/ROOT/public/system/users/avatars/000/000/010/thumb/123.jpg
  Redirected to url
  
  
  Encoding::UndefinedConversionError - "\xFF" from ASCII-8BIT to UTF-8:
    org/jruby/RubyString.java:7580:in `encode'
    (gem) activesupport-3.2.13/lib/active_support/json/encoding.rb:123:in `escape'
    (gem) activesupport-3.2.13/lib/active_support/json/encoding.rb:69:in `escape'
    (gem) activesupport-3.2.13/lib/active_support/json/encoding.rb:171:in `encode_json'
    (gem) activesupport-3.2.13/lib/active_support/json/encoding.rb:214:in `encode_json'
    org/jruby/RubyArray.java:2361:in `map'
    (gem) activesupport-3.2.13/lib/active_support/json/encoding.rb:214:in `encode_json'
    (gem) activesupport-3.2.13/lib/active_support/json/encoding.rb:48:in `encode'
    (gem) activesupport-3.2.13/lib/active_support/json/encoding.rb:77:in `check_for_circular_references'
    (gem) activesupport-3.2.13/lib/active_support/json/encoding.rb:46:in `encode'
    (gem) activesupport-3.2.13/lib/active_support/json/encoding.rb:246:in `encode_json'
    org/jruby/RubyHash.java:1257:in `each'
    org/jruby/RubyEnumerable.java:718:in `map'
    (gem) activesupport-3.2.13/lib/active_support/json/encoding.rb:246:in `encode_json'
    (gem) activesupport-3.2.13/lib/active_support/json/encoding.rb:48:in `
  </code></pre>
  
  <p>I checked with the paperclip gem and it uses binmode for opening  the file.</p>