Ruby の「each」ステートメントでデータにアクセスできません。SQL クエリからデータを取得しています。
mysql> select * from mantis_bug_relationship_table WHERE relationship_type = 2 AND destination_bug_id = 753;
+-----+---------------+--------------------+-------------------+
| id | source_bug_id | destination_bug_id | relationship_type |
+-----+---------------+--------------------+-------------------+
| 103 | 765 | 753 | 2 |
+-----+---------------+--------------------+-------------------+
次に、各結果を次のような配列に追加して、relationship_type が 2 になるようにします。
parent_map = {}
current = 1
# for each loop is here that populates parent_map
parent_map[current] = { issues_map[relation.destination_bug_id] => issues_map[relation.source_bug_id] }
current += 1
# for each loop is here that populates parent_map
次に、次のようにparent_mapからデータを読み取ろうとします:
parent_map.each do |child, parent|
pp parent_map
print "child: #{child}\n"
print "parent: #{parent}\n"
print "---------------------------------------\n"
STDOUT.flush
end
これは次のように出力されます。
{1=>{753=>765}}
child: 1
parent: 753765
出力は次のようになります。
child: 753
parent: 765
子と親にアクセスするにはどうすればよいですか?