`

ror支持中文

阅读更多
在app文件中的application.rb 文件中增加过滤方法,
  before_filter :configure_charsets
      def configure_charsets
          # @headers["Content-Type"] = "text/html; charset=utf-8"
          @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
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics