相关疑难解决方法(0)

Rails 3 - 如何处理PG错误不完整的多字节字符

在Rails 3.2应用程序(Ruby 1.9.2)中,我收到以下错误

在mobile_users#update中发生了PGError:

不完整的多字节字符

这些是Postgres错误我在开发和测试模式下测试时遇到类似的SQLIte错误

导致此错误的参数是(故意省略auth令牌)

  * Parameters: {"mobile_user"=>{"quiz_id"=>"1", "auth"=>"xxx", "name"=>"Joaqu\xEDn"}, "action"=>"update", "controller"=>"mobile_users", "id"=>"1", "format"=>"mobile"}
Run Code Online (Sandbox Code Playgroud)

这是作为JSON HTTP Put请求进行的,处理此问题的更新操作如下所示

  # PUT /mobile_users/1
  # PUT /mobile_users/1.xml
  def update
    @mobile_user = current_mobile_user
    @mobile_user.attributes = params[:mobile_user]

    respond_to do |format|
      if @mobile_user.save
        format.html { redirect_to(@mobile_user, :notice => 'Mobile user was successfully updated.') }
        format.json  { head :ok }
        format.mobile  { head :ok }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.json  { render :json => @mobile_user.errors, :status => …
Run Code Online (Sandbox Code Playgroud)

ruby encoding ruby-on-rails utf-8

2
推荐指数
1
解决办法
2444
查看次数

标签 统计

encoding ×1

ruby ×1

ruby-on-rails ×1

utf-8 ×1