2006/10/17

配置rails使用中文

before_filter :configure_charsets

def configure_charsets
@response.headers["Content-Type"] ="text/html; charset=utf-8"
# Set connection charset. MySQL 4.0 doesn’t support this so it
# will throw an error, MySQL 4.1 needs this
suppress(ActiveRecord::StatementInvalid) do
ActiveRecord::Base.connection.execute 'SET NAMES UTF8'
end
end
将以上内容添加到Application.rb中即可。

没有评论:

发表评论

Mastodon Daily 2026-07-21

时间范围: 7/21/2026, 12:00:00 AM - 7/21/2026, 11:59:59 PM (Asia/Shanghai) 共 4 条帖子 前东家的股票跌的不行了。 # 有点懈怠 # 有清仓一支股票。 # 眼镜已经是...