InstantRailsで日本語を扱う際にすること
1. mysqlの設定ファイル(InstantRails\mysql\my.ini)の[mysqld]に一行追加
default-character-set=utf8
2. controllers/application.rb に以下のコードを追記
before_filter :set_charset protected def set_charset @headers['Content-Type'] = 'text/html; charset=utf-8' suppress(ActiveRecord::StatementInvalid) do ActiveRecord::Base.connection.execute 'SET NAMES UTF8' end end