0

I have the following situation: My webservice is receiving JSON data and creating models (typical REST scenario). Sometimes I get a

Encoding::CompatibilityError Exception: incompatible character encodings: ASCII-8BIT and UTF-8

error message when saving the records, which can only be (or is) bound to two attributes. Firing up the debugger, setting ANY of those two attributes to an empty string and saving works, like so:

model = Model.new(params[:model])
model.save! # Fails with above error message

model = Model.new(params[:model])
model.attribute1 = ""
model.save! # Works

model = Model.new(params[:model])
model.attribute2 = ""
model.save! # Works too!

Now the params are parsed from the http request, how can they be dependent on each other?

Anyone with the same scenario?

Edit: We've found the reason for the compability error: https://github.com/jruby/activerecord-jdbc-adapter/issues/229 As it seems, the JDBC adapter has some errors with utf-8 encoding, something which has been fixed for a long time in traditional rubies.

Christoph Lupprich
  • 1,170
  • 8
  • 16

1 Answers1

0

As added in the edit to my original question, the problem is a bug in the JDBC adapter of JRuby (which I forgot to add as a constraint, my bad!): https://github.com/jruby/activerecord-jdbc-adapter/issues/229

Christoph Lupprich
  • 1,170
  • 8
  • 16