MySQL support for UTF-8 in Ruby on Rails

As a follow-up to my post about MySQL support for UTF-8 in PHP, here is the very same information for Ruby on Rails. In Rails it is a simple configuration entry in config/database.yml. I use the development configuration as an example:

development:
  adapter: mysql
  database: dev
  username: dev
  password: secret
  socket: /var/run/mysqld/mysqld.sock
  encoding: UTF8

UTF-8 is obviously configured with the encoding setting. Don’t forget to update the test and production databases too!

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.