我從外部服務接收這些格式中的任何一種。TypeError:在處理多種哈希時,不會將符號隱式轉換爲整數
#successCase:如果成功/錯誤,這將適當狀態代碼拋出
{:sellerid=>2200, :status=>"success"}
#failureCase:的意外錯誤我recieving這種散列這也是造成錯誤
{:property=>"instance.seller_mobile", :message=>"does not meet maximum length of 10", :schema=>{:type=>"string", :required=>true, :minLength=>1, :maxLength=>10}, :instance=>"ssss56789", :stack=>"instance.seller_mobile does not meet maximum length of 10"}
這就是我做的響應,這裏是錯誤發生的地方(我認爲)
`if response[:status] == 'success'`
#doing something
elsif response[:status] == 'error'
#doing something
end
如果它的#successCase:迴應這工作正常。但是,如果其#failureCase:我得到錯誤
TypeError: no implicit conversion of Symbol into Integer
我可以看到它在這裏養錯誤Failure/Error: if parsed_response[:status] == 'success'
有人能告訴我如何解決這一問題?
PS: "I tried in console and it seems to be working right but rails throws error"
對於failureCase散列是否有':status'鍵?和/或任何「錯誤」值? –
@SebastiánPalmano .. – Abhilash
你知道Ruby和Rails版本嗎? –