V
Valentino Lun
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.findall).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
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.findall).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