I am recieving either of these formats from an external service.
#successCase: if success/error this will be thrown with proper status code
{:sellerid=>2200, :status=>"success"}
#failureCase: for unexpected errors am recieving this kind of hash and this is causing errors
{:property=>"instance.seller_mobile", :message=>"does not meet maximum length of 10", :schema=>{:type=>"string", :required=>true, :minLength=>1, :maxLength=>10}, :instance=>"01234ssss56789", :stack=>"instance.seller_mobile does not meet maximum length of 10"}
This is what I do with the response and here is where error happens(I think)
`if response[:status] == 'success'`
#doing something
elsif response[:status] == 'error'
#doing something
end
If its #successCase: response this works fine. But if its #failureCase: am getting error
TypeError: no implicit conversion of Symbol into Integer
I can see that its raising error here Failure/Error: if parsed_response[:status] == 'success'
Could someone tell me how to fix this?
PS: "I tried in console and it seems to be working right but rails throws error"
:status
key? and/or anyerror
value? – Sebastian Palmaruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
&Rails 5.0.1
– Abhilash[:status]
will then complain that:status
can not be converted from Symbol to Integer, the only allowed argument type forArray#[]
. – Michael Kohl