Having a form that submits a file, when reading with:
file = params[:file]
@file = file.read
and presenting in a view
<%= @file %>
Shows the error: incompatible character encodings: ASCII-8BIT and UTF-8
But if we read with
file = File.read(params[:file].path)
Just tested it out with Rails 4.1.0beta & Ruby 2.0.0-p0, and it worked slick for me.
Pre-Ruby2 is a bit messy when it comes to encodings. Sometimes you need to explicitly state which encoding you want to open the file with (which is less than ideal).
@pedrogaspar can you post an isolated sample application that shows the problem and upload it to github?
@pedrogaspar It's been a month since we heard from you. Without further debugging information it's hard to track the issue down. I'm closing this one but please report back if you still experience this problem.
Thanks for reporting.