---
title: "rails中修改页面和应用的字符集"
author: "fourfire"
date: "2007-01-10T05:36:20Z"
tags: []
slug: "rails"
draft: false
lastmod: "2007-01-10T05:36:20Z"
id: 45769
url: "https://fourfire.iteye.com/blog/45769"
---

整个应用中字符集换为gbk：1 打开Rails目录中的.app/controllers/application.rb2 增加过滤器代码before\_filter :set\_charsetdef set\_charset@headers\["Content-Type"] = "text/html; charset=gbk"end单个页面增加&lt;%@headers\["Content-Type"] = "text/html; charset=gbk"%&gt;即可Ruby on rails