Is it true that if $R$ is a commutative ring such that every maximal ideal of $R$ is generated by an idempotent, then $R$ is a PIR?
I thought this solution: If $P$ is a prime ideal such that isn't maximal, then by Krull's theorem $P$ is contained properly in a maximal ideal $M$. By hypothesis, $M=(e)$, where $e^2=e$. So $e(1-e)=0\in P$, so since $P$ is prime, either $e\in P$ or $1-e\in P$. If $e\in P$, then $(e)\subseteq P$, i.e., $M\subseteq P$, contradiction. So $1-e\in P\subset M$, and thus $e+(1-e)=1\in M$, hence $M=R$, contradiction again. Therefore, every prime ideal is maximal, and then every prime ideal of $R$ is principal (by hypothesis), so by a well-known theorem (I think this result is a theorem of Kaplansky analogous to Cohen's theorem for noetherian rings), $R$ is a PIR.
Is my proof right? Thanks in advance.