title: Rails - Traversing a json hashes and arrays with HTTParty
body: <p>So I've got the below business happening, which works... but even as a rookie, I'm thinking it looks pretty horrid.</p>
  
  <p>The structure is that:
  "Each product has an array of artists. Only return the products with the correct artist" </p>
  
  <pre><code>def fetch_products(artist)
    result = get("/#{@id}/products.js", :headers =&gt; {'Accept' =&gt; 'application/json'})
    products = []
  
    result.each do |product| 
      if not product['artists'].find_all {|i| i['name'].downcase == artist.downcase }.empty?
        products &lt;&lt; product
      end
    end
    products
  end    
  </code></pre>
  
  <p>If anyone's got any tips I'd love get some better understanding on a 'better' and/or 'faster' way to do this!</p>