扱う文字コードをUTF-8に設定します。
1./config/enviroment.rbの編集
/config/enviroment.rb |
# Be sure to restart your server when you modify this file
$KCODE = 'u'
:
:
Rails::Initializer.run do |config|
:
:
# Make Time.zone default to the specified zone, and make Active Record store time values
# in the database in UTC, and return them converted to the specified local zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Comment line to use default local time.
config.time_zone = 'Tokyo'
:
:
end
|
2./app/controllers/application.rbの編集
/app/controllers/application.rb |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.class ApplicationController < ActionController::Base
before_filter :set_charset
private
def set_charset
headers['Content-Type']="text/html; charset=utf-8"
end
:
:
:
end
|