Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Encoding::CompatibilityError after changing to OkJson backend #9122

Closed
renatosnrg opened this Issue · 5 comments

3 participants

@renatosnrg

After updating my Rails applications to the new 3.0.20 version (which fixes CVE-2013-0333), I'm getting this error: Encoding::CompatibilityError - incompatible character encodings: UTF-8 and ASCII-8BIT

Investigating the commit 5375dce (Add an OkJson backend and remove the YAML backend) I could notice that the line "# encoding: UTF-8" is not at the top of the file. Moving it to the top fixes the issue.

@zmoazeni

@renatosnrg That sounds awfully similar to what we debugged yesterday in our apps. Your error message isn't the same as what we had, but very close. We resolved to use the JSONGem, which "just works".

  1. Make sure json is installed as a gem (this might be a rails dependency, not sure).
  2. Put this in one of your initializers: ActiveSupport::JSON.backend = "JSONGem"

That might fix your issue. This is what we tracked the issue down to: #9121 (comment)

@zmoazeni

Reading fail on my part. Sorry. Your solution fixes my issue too.

@zmoazeni

Thanks!

@renatosnrg

I wanna thank Ingo for this fix, he was the first to solve the problem in ours apps, I just commited his solution (unfortunately he doesn't have a Github account).

Thanks!

@renatosnrg

We continue having issues with accented chars :(
Migrating backend to "JSONGem" fixed the problem!

By the way, does anyone know why OkJson was chosen as ActiveSupport default backend?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.