The Phillies snapped a three-game losing streak and handed the Padres a National League-high 22nd loss in 33 games this year.
Mayberry hit a two-run homer in the second inning to open the scoring and, after San Diego tied it in the fourth, Ruiz produced a two-run blast in the bottom half of the frame to give the Phillies the lead for good.
Both Ruiz and Mayberry added an RBI single in the seventh.
Vance Worley (3-2) struck out nine over six innings to get the win. He allowed three runs on six hits after being touched for five runs on 11 hits in his previous start against Washington.
The home runs by Ruiz and Mayberry came off Clayton Richard (1-5), who surrendered five runs on eight hits over 5 1/3 innings.
Celebrity Breakups and divorces of 2014 [PHOTOS]