-
-
Save alexggordon/f8359b160559358fb12b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I need to turn | |
[ {:class_fk => 1234, :criteria => "citizenship", :grade => "A"}, | |
{:class_fk => 1234, :criteria => "effort", :grade => "B"} ] | |
# into | |
{ 1234 => {"citizenship" => "A", "effort" => "B"} } | |
# I have this | |
@citizenship_effort = @citizenship_effort.map {|v| {class_pk: v[:class_pk], v[:criteria] => v[:grade]}}.group_by {|x| x[:class_pk]} | |
# but it results in | |
{1234=>[{:class_pk=>1234, "citizenship"=>"A"}, {:class_pk=>1234, "Effort"=>"B"}] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment