title: loop through array of hashes
body: <pre><code>name: {
          "accounts"=&gt;{
            "data"=&gt;[
  
                {
                "access_token"=&gt;"CAAUCR7n0ZC50BAGmqTb3FEYz9FzZCZAZBFdVZC6AM3iQrGUsVqWvCfI5q5vh4seRH6LwIQTSkZAznzeBaPlZBjQ3zcwdfWxPBIr78FZBVa8pymUzVX0UESSS7QC0Dm7iIUCMyRH175HV6ZCa2ugBmbJNB7joZB7oiILPH5jtpcCLkg8e7ztxyjeSODSO4ZBAM9z1pkZD",
                "name"=&gt;"UNX",
                "id"=&gt;"387832931391777",
                },
                {
                "access_token"=&gt;"CAAUCR7n0ZC50BAEYnXR7bWGvhktsGXCaB43vB0mhSuKgZBQG1m5FyovssyVKt0XYv7K7essxPkVPU3nQZCqrQJeTtWhApV1cSYGsb4JbNmYlUiHmLHueEBjuomqRWVX6tvMZA0dA5zqMApbmPUtA7SBqruWUFzZAwZC9xZBXFMZCZAW7WNEL7epkb9dmiL2pX3AoZD",
                "name"=&gt;"Fuitter",
                "id"=&gt;"1412081982453898",
                }
                ]}}
  </code></pre>
  
  <p>I am trying to get the <code>name</code> key from the <code>data</code> array of hashes. I have used <code>each</code> to loop but that way I had to nest loop inside of loop. Is there another way to make this work?</p>
  
  <p>This <code>name</code> key is actually column in my database of data type json. </p>
  
  <pre><code>&lt;% session[:user].account.name.each do |test| %&gt;
    &lt;% test.each do |me| %&gt;
      &lt;%= me['data']['name']%&gt; #unable to fetch name and gives me undefined method `[]' for nil:NilClass error 
      &lt;br&gt;
    &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I am trying to get the value by nesting loops, but I got this error</p>
  
  <pre><code>unable to fetch name and gives me undefined method `[]' for nil:NilClass error 
  </code></pre>