[verb (dictionary form)] + ほうがましだ [verb た-form] + ほうがましだ [verb ない-form] + ほうがましだ [i-adj] + ほうがましだ [na-adj] + な + ほうがましだ [noun] + の + ほうがましだ [verb (dictionary form)] + くらいなら、 + … + ほうがましだ
ほうがましだ means "I'd rather", "it would be better to": neither choice is good, and this one is less bad. The worse option usually comes first with くらいなら or より. Verbs and adjectives go in the plain form, a な-adjective keeps な, and a noun takes の.
These go beyond the present-tense comparison.
Without ほう, よりましだ puts the worse option right before まし: "it's better than …".
In the past it is a regret: it would have been better to do the other thing.