3

画像を渡そうとすると、次のエラーが発生します。

!! Unexpected error while processing request: invalid byte sequence in UTF-8

奇妙なことに、レイズ (以下) が実行されませんでした。

私の質問は次のとおりです。これがどのようにしてこのエラーを引き起こす可能性がありますか? ヘッダーまたはパラメーターと関係がありますか?

ここで何か助けていただければ幸いです。

  def create
    raise "request did get executed in code here"
    debugger
    @asset = nil
    if params && params[:asset]
      p = params[:asset]
      if p[:file]
        user_id = p[:user_id] || current_user.try(:id)
        checksum = p[:checksum] || Util.file_checksum(p[:file].path)
        if user_id.present? && checksum.present?
          options = {:taken_at => p[:taken_at] || Util.file_taken_at(p[:file].path)}
          @asset = Asset.create user_id, checksum, p[:file], p[:file].original_filename, options
        end
      end
    end

    respond_to do |format|
      if @asset && @asset.state != QueueItem::STATE_NONE
        format.html { head :no_content }
        format.json { render :json => @asset, :status => :created }
      else
        format.html { head :no_content }
        format.json { render :json => @asset.try(:errors), :status => :unprocessable_entity }
      end
    end
  end
4

1 に答える 1

0

コントローラーの最初の行を次のように設定します: #encoding: UTF-8

于 2013-09-05T08:22:39.800 に答える