before_filter :configure_charsets将以上内容添加到Application.rb中即可。
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
2006/10/17
配置rails使用中文
订阅:
博文评论 (Atom)
Mastodon Daily 2026-09-09
时间范围: 9/9/2026, 12:00:00 AM - 9/9/2026, 11:59:59 PM (Asia/Shanghai) 共 2 条帖子 继续开发。 # 何去何从。 #
-
使用 Cloudflare Tunnel 的 TryCloudflare 取代 ngrok ...
-
https://t.co/uNZYlXmkBs 纪录片《老摇滚》,不到1分钟就爆燃,25分钟的时候泪目…… 2017年就要过去了,我很怀念她,也怀念曾经还热爱摇滚乐的日子。 推荐大家看看这部纪录片,在这个辞旧迎新的时刻。 — 零零发 (@linglingfa) Dec...
-
I just watched AIBOU 23x13 "Episode 13" https://trakt.tv/shows/aibou/seasons/...
没有评论:
发表评论