The problem you're running into has to do with encoding mismatch
(under ruby 1.9) in some data you're munging/rendering in that view.
First thing you should do is check your config/setup regarding
$ ./script/rails console...> __ENCODING__ => #<Encoding:UTF-8>
Encoding.default_internal => #<Encoding:UTF-8>
Encoding.default_external => #<Encoding:UTF-8>
ActiveRecord::Base.configurations[Rails.env]["encoding"] => "utf8" ...
Assuming your stack is properly setup for utf-8, then the most likely
culprit is that you have some non-utf-8 binary char(s) in some data
that is causing the problem (probably copy/pasted from ms-word into
Not the same error, but here's an example of a similar encoding-
s = "foo™" => "foo™"
s.sub(/foo/, 'bar') => "bar™"
s2 = "foo™".force_encoding("ASCII")
ArgumentError: invalid byte sequence in US-ASCII
You can test/log the underlying data you're trying to render in that
view to see what exactly is causing the problem in order to delete/
The bigger issue is ... how to prevent and/or deal with this
particular case when it happens again? Probably many diff ways to
deal with this, but in such cases where I need to force the encoding
to be valid utf-8 for a given submitted string no matter what, I've
used something like the following:
IC_UTF8 = Iconv.new('UTF-8//IGNORE', 'UTF-8')
#note added extra space plus chop to fix certain cases.
s3 = force_utf8(s2) => "foo™"
On Dec 29 2011, 6:45 pm, gerbdla wrote:
yeah this is actually in a view that the error is occurring. I have
tried to put this encoding statement in the view
but to no avail. hopefully someone has had this problem and can
instruct me . It seems
like this would be a common error.
On Dec 29, 3:30 pm, Javier Quarite wrote:
On Thu, Dec 29, 2011 at 6:19 PM, gerbdla wrote:
This is the full error anyone else having this issue?
incompatible character encodings: UTF-8 and ASCII-8BIT
activesupport (3.0.9) lib/active_support/core_ext/string/
Well I'm not having the same issue, but when I wanted to create a csv file
in my controller and one of the cells contains
this -> ` rails is expecting something else, so I just add at the
beggining of my controller the following
and worked, maybe it helps
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to firstname.lastname@example.org.
To unsubscribe from this group, send email to email@example.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.