3
我正在試圖在圖像中傳遞時這個錯誤:意外的錯誤,同時處理請求:無效的字節序列UTF-8
!! 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
也許你需要這個http://stackoverflow.com/questions/9607554/ruby-invalid-byte-sequence -in-utf-8 – Thanh
您是否嘗試過在文件頂部使用魔術註釋:'#Encoding:utf-8'。 – Kris
老問題,但我想我已經和Webrick有過這樣的問題。如果您使用Webrick,請嘗試使用獨角獸。 – Arkan