A general and easy to prove fact:
Fact: Let $R$ be a ring. Then $(r)=R$ if and only if $r\in R^\times$ (i.e. $r$ is a unit in $R$).
Proof. If $r$ is a unit then there is some $s\in R$ such that $s\cdot r=1$. Hence, $1\in(r)$ and so $a=a\cdot1\in(r)$ for all $a\in R$. So $R\subseteq(r)$ and consequently $(r)=R$. Conversely assume that $(r)=R$. Then in particular $1\in(r)$. But then by definition $s\cdot r=1$ for some $s\in R$, that is, $r$ is a unit.$~\square$
Now suppose the only ideals of your ring are $\{0\}$ and $R$. If $r\ne0$, then $(r)\ne\{0\}$ as $r\in(r)$. Thus $(r)=R$ and by the aforegoing fact it follows that $r\in R^\times$. As $r$ was an arbitrary non-zero element of our ring we conclude that every such element is invertible and hence $R^\times=R\setminus\{0\}$. Given that $R$ is commutative and unital we see that then $R$ is in fact a field.