What is the default valule for "encoding" in ActiveRecord::Base.establish_connection

Hi guys,

I am using mysql. Recently I changed the character set from Latin1 to
UTF-8.
I met an issue when I inserted a new record. It showed up some illegal
characters. Per my test, I thought it converted the value from UTF-8 to
Latin1 and then saved in table.

If I add “:encoding => “utf8”” to establiash_connection method, the
problem will be solved. Is there any default value for :encoding in
establish_connection?

ActiveRecord::Base.establish_connection(
:adapter => “mysql”,
:host => “localhost”,
:username => “edwin”,
:password => “123456”,
:database => “products”
)

Thanks in advance

question closed. I didn’t figure out a way to get the default value for
encoding. But when I set the :encoding to “latin1”, I will get the same
result.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs