Why does this Ruby statement throw an exception? (Arrays/Bools) -


I'm not a Ruby man, I just play one on television. I have to modify some old chron job to pull some Jason down and turn into objects.

Here is the code

  raw_json = Net :: HTTP.get (URI parsing ("URL is removed to protect innocent")) Tags = ActiveSupport: JSON .decode (raw_json) tags.count  

detects tag.count 5 correctly, but that line is immediately the reason for the crash:

  5 # Counts right! Rack abortion! Undefined method for false `count ': FalseClass  

What is the dealerio?

What is the content of raw_json ? What seems to be happening is that returning ActiveSupport :: JSON # decode (hence the undefined method is false for 'fault': FalseClass ). I think that JSON # decode returns false if only given empty string, which means that HTTP # get is returning an empty string raw_json < Check / code> and see what is expected in it.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -