I recently wrote this post on the topic. I hope it helps. I will soon also add the code in another post.
Here is an outline of what it entails:
One decision you have to make is if you have a kind of sub-match or not. For example: In foosball, you will see that in a 2v2 game there are always two players facing each other directly and two indirectly. That means: the two defenders never really interact, it's only the attacker-defender pairs. The alternative is a scenario like Dota which is 5v5 and there are no real individual, predictable 1v1 matchups as part of the real match.
Case one: No sub-match structure:
In this case, you can simply average the rating of all players involved and use that as a team-rating for that team. So for R_a and R_b, you would simply use the sum of the ratings of all players of that team, divided by the number of players. Once you have computed the update for the team, you update every team-members rating with the update.
Case two: Sub-matches:
In this case, you split into sub-matches and weigh them against each other. So you compute E_a and E_b for every pair and then weigh these. For example: For 5v5 with a 1v1 sub-structure you compute the 5 E_a values for the 5 pairs. Then you compute a weighted term for every individual player based on the sub-match he is a part of. So if player 1 is part of submatch 1, you compute something like 0.6*E_a1 + 0.1*E_a2+ 0.1*E_a3+ 0.1*E_a4+ 0.1*E_a5 (where E_a1 is E_a for the sub-match the player is involved in).
The parameters here can be freely chosen, but you can optimize them once you have some data. Try to find a weighting scheme for which the player ratings don't fluctuate as much. This can be done automatically by computing the variance fo the values and then minimizing that for a given set of match results by adapting the weights.
I hope this is helpful.