thank_you
thank_you

Reputation: 11107

incompatible character encodings: ASCII-8BIT and UTF-8 and debug(params)

I'm receiving this error whenever I edit an user's information. The localhost tells me that the error occured around this line...

<%= debug(params) if Rails.env.development? %>

Parameters returned...

{"utf8"=>"✓",
 "_method"=>"put",
 "authenticity_token"=>"hC/BQTSBodv+qlvhYnxJ4mqMl+w3G1FLwopxpbmsm/g=",
 "user"=>{"name"=>"jason",
 "email"=>"jason1",
 "password"=>"[FILTERED]",
 "password_confirmation"=>"[FILTERED]"},
 "commit"=>"Save changes",
 "id"=>"7"}

What's causing this error and how do I fix it?

Upvotes: 2

Views: 1622

Answers (1)

ceth
ceth

Reputation: 45295

  1. Try to recreate your template file from scratch in a UTF-8 friendly editor.
  2. Put config.encoding = "utf-8" in your application.rb file.
  3. Add this code in your environment.rb:

    Encoding.default_external = Encoding::UTF_8
    Encoding.default_internal = Encoding::UTF_8

  4. If you are working with MySql use the "mysql2" gem.

  5. Put # encoding: utf-8 at the top of your file.

Upvotes: 2

Related Questions