I want to merge these two arrays based on uniqueness:
"template_variables": [{
"info_top": "Some string"
}, {
"info_bottom": "Other string"
}],
"user_variables": [{
"info_top": "Default string"
}, {
"info_bottom": "Other default string"
}, {
"other_info": "Default number"
}]
So if I start with the user_variables
array and add template_variables
to it, replacing hashes where matches are found.
My desired output would be:
"new_variables": [{
"info_top": "Some string"
}, {
"info_bottom": "Other string"
}, {
"other_info": "Default number"
}]
I've tried user_variables.merge(template_variables)
and variations on that, but that's not suitable for an array of hashes, it seems.
How do I do this?