Leinster emerged from the break with renewed energy and racked up 14 unanswered points to lead 27-21 before the hour – Jonny Sexton converting scores from James Ryan and Sean Cronin.
It was not enough for the defending champions, though, as Medard crossed with 12 minutes remaining, enabling Ramos to kick the match-winning points.
Victory ensured Toulouse maintained their 100 per cent record after two matches, a feat shared by Newcastle Falcons in Pool 5.
— Newcastle Falcons (@FalconsRugby) October 21, 2018
The Falcons left it extremely late to seal a 23-20 success over Montpellier, Callum Chick crossing nearly nine minutes after the clock went into the red.
Ruan Pienaar had kicked Montpellier into the lead after trailing at half-time, but a 39-phase move opened the door for Chick and he duly accepted to move Newcastle to the top of the table.
Hastings, DTH van der Merwe and Ali Price all crossed in the opening 40 minutes and, although Cardiff tried to fight their way back, Glasgow proved too strong.
Sign up to our mailing list here and we’ll keep you up to the minute with weekly updates from the world of rugby.