Abubakar Azeem
Abubakar Azeem

Reputation: 324

How to get default collation in rails?

In database.yml i have this configuration:

  development:
      adapter: mysql2
      encoding: utf8
      ...

But ActiveRecord::Base.connection.collation returns latin1_swedish_ci this is not what i expected, because default collation is utf8_unicode_ci. How can i get default collation in rails?

Upvotes: 5

Views: 4231

Answers (1)

Kamal Panhwar
Kamal Panhwar

Reputation: 2399

As per my knowledge you can check it on two places, remember you have also to check your mysql database. For ruby on rails you can check configuration and add as per following at end of your database.yml file

encoding: utf8mb4
collation: utf8mb4_unicode_ci

Restart server and now it should be following this configuration. Than check with following command

ActiveRecord::Base.connection.collation

Now let us check on mysql

mysql> show variables like 'collation%';

Right now I can't check these things as mysql is not setup, so will edit later to confirm you all.

Upvotes: 10

Related Questions