The Costa Rica international shone in the Estadio Nacional, creating one and scoring another as Martin Jol's side maintained their unbeaten run in Central America.
Steve Sidwell and Dimitar Berbatov netted the other two goals as the Premier League side continued their preparations ahead of the new campaign.
After struggling to break through the hosts' defence in the first half, Fulham were grateful to new goalkeeper Maarten Stekelenburg for keeping them in the game. The Dutchman made good saves from Kevin Sancho and Cristian Oviedo in the first half while Alfonso Quesada did the same at the other end, denying Sidwell and Berbatov.
Fulham took the lead just after the hour mark when Sidwell evaded his marker and climbed highest to meet a Ruiz corner, the midfielder's header perfectly placed to beat the dive of Quesada. However, the advantage only lasted 10 minutes when Allen Guevara equalised for the hosts after slack defending.
With 11 minutes to play, Fulham took the lead for a second time as substitute Alexander Kacaniklic burst into the Alajeunese penalty area and was brought down by Elias Palma, with Berbatov stepping up to score the spot-kick for his third goal in two matches.
Ruiz then wrapped things up late on, the forward outpacing the home defence and firing past Quesada to seal the victory.