title: Loop through array of hashes with rails
body: <p>So I am trying to grab all <em>high schools</em> and <em>graduate schools</em> from this array of hashes:</p>
  
  <pre><code>"education": [
      {
        "school": {
          "id": "110703012290674", 
          "name": "Kunskapsgymnasiet Malmö"
        }, 
        "year": {
          "id": "136328419721520", 
          "name": "2009"
        }, 
        "type": "High School"
      }, 
      {
        "school": {
          "id": "112812485399398", 
          "name": "Malmö University"
        }, 
        "year": {
          "id": "118118634930920", 
          "name": "2012"
        }, 
        "concentration": [
          {
            "id": "104076956295773", 
            "name": "Computer Science"
          }
        ], 
        "type": "Graduate School", 
        "classes": [
          {
            "id": "165093923542525", 
            "name": "Programmering", 
            "description": "Kursen fokuserar på metoder och tekniker vid utveckling av webbapplikationer med hjälp av HTML5."
          }
        ]
      }
    ],
  </code></pre>
  
  <p>Like this:</p>
  
  <pre><code>if auth["extra"]["raw_info"]["education"]  
  
          # hash/array element 0
          if auth["extra"]["raw_info"]["education"][0]["type"] == "High School" 
            user.highschool_name = auth["extra"]["raw_info"]["education"][0]["school"]["name"] if (!auth["extra"].blank? &amp;&amp; !auth["extra"]["raw_info"]["education"][0]["school"].blank?)
            user.highschool_year = auth["extra"]["raw_info"]["education"][0]["year"]["name"] if (!auth["extra"].blank? &amp;&amp; !auth["extra"]["raw_info"]["education"][0]["year"].blank?)
  
          elsif auth["extra"]["raw_info"]["education"][0]["type"] == "Graduate School"
            user.graduateschool_name = auth["extra"]["raw_info"]["education"][0]["school"]["name"] if (!auth["extra"].blank? &amp;&amp; !auth["extra"]["raw_info"]["education"][0]["school"].blank?)
            user.graduateschool_year = auth["extra"]["raw_info"]["education"][0]["year"]["name"] if (!auth["extra"].blank? &amp;&amp; !auth["extra"]["raw_info"]["education"][0]["year"].blank?)
          end
  
          # hash/array element 1 
          if auth["extra"]["raw_info"]["education"][1]["type"] == "High School"
            user.highschool_name = auth["extra"]["raw_info"]["education"][1]["school"]["name"] if (!auth["extra"].blank? &amp;&amp; !auth["extra"]["raw_info"]["education"][1]["school"].blank?)
            user.highschool_year = auth["extra"]["raw_info"]["education"][1]["year"]["name"] if (!auth["extra"].blank? &amp;&amp; !auth["extra"]["raw_info"]["education"][1]["year"].blank?)
  
          elsif auth["extra"]["raw_info"]["education"][1]["type"] == "Graduate School"        
            user.graduateschool_name = auth["extra"]["raw_info"]["education"][1]["school"]["name"] if (!auth["extra"].blank? &amp;&amp; !auth["extra"]["raw_info"]["education"][1]["school"].blank?)
            user.graduateschool_year = auth["extra"]["raw_info"]["education"][1]["year"]["name"] if (!auth["extra"].blank? &amp;&amp; !auth["extra"]["raw_info"]["education"][1]["year"].blank?)
          end
        end
  </code></pre>
  
  <p>Is there a more efficient way to do it, like a loop of somekind? Any great ideas?</p>