RoR 中 Prototype 的中文乱码

今天在写 Ruby on Rails 的时候发现,AJAX 传回中文数据会出现乱码。搜索以后发现原来可以这样做。在 controller 中加入

before_filter :set_charset def set_charset @headers["Content-Type"] = 'text/html; charset=gb2312"; end

我很懒,直接写到 ApplicatiopnController 中了,搞定。

No comments

Post a comment

Comment Guidelines

  • We use Markdown here.
  • Have no more than 2 links.
  • Register Gravatar if you want an avatar displayed.