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

你可能感兴趣的:(html,mysql,ActiveRecord)