From: Valentino Lun Date: 2009-01-15T17:23:42+09:00 Subject: A Hash problem Dear all I want to build a hash which store the values from database, but failed. Please give me some hints please. Thank you. services table h_code s_code status AHN BBS 3 AHN MBS 1 AHN HMS 1 CMC CRS 1 CMC CPS 1 CMC BTNS 1 GH CRS 1 GH CPS 1 My expectation all = {"AHN" => {"BBS" => 3, "MBS" => 1, "HMS" => 1} "CMC" => {"CRS" => 1, "CPS" => 1, "BTNS" => 1} "GH" => {"CRS" = 1, "CPS" => 1} } all = {} Service.find(:all).each do |s| # How to do here? # I try all[s.h_code][s.s_code]=s.status, but not work end Thank you very much Valentino -- Posted via http://www.ruby-forum.com/.