Let $R$ be a UFD. Prove that $R$ is a PID if every nonzero prime ideal in $R$ is maximal.
The author gives the following hint: assume that every nonzero prime ideal of $R$ is maximal, and prove that every maximal ideal in $R$ is principal; then use Proposition 3.5 to relate arbitrary ideals to maximal ones, and prove that every ideal of $R$ is principal
Proposition 3.5. Let $I ≠( 1 )$ be a proper ideal of a commutative ring $R$. Then there exists a maximal ideal $\frak{m}$ of $R$ containing $I$.
I could prove every maximal ideals is principal, but then I got stuck. I know the question has been asked in MSE, but I couldn't find an answer that use the same method as the hint, so I really want to know how to use the method