I have the following list:
hash_list =
{ "a"=>{"unit_id"=>"43", "dep_id"=>"153","_destroy"=>"false"},
"b"=>{"unit_id"=>"43", "dep_id"=>"153", "_destroy"=>"1"},
"c"=>{"unit_id"=>"43", "dep_id"=>"154", "_destroy"=>"false"},
"d"=>{"unit_id"=>"42", "dep_id"=>"154", "_destroy"=>"false"}
}
I need the result as:
{
"a"=>{"unit_id"=>"43", "dep_id"=>"153", "_destroy"=>"false"},
"b"=>{"unit_id"=>"43", "dep_id"=>"153", "_destroy"=>"1"},
"d"=>{"unit_id"=>"42", "dep_id"=>"154", "_destroy"=>"false"}
}
Basically , the unit_id
should not repeat. But, all _destroy=="1"
, entries can appear in the list.
Please help.
Try this:
This will check for
unit_id
as uniq and also let appear"_destory" == "1"
entries as you have mention.