The converse is not true. Consider the ring $R=\mathbb{C}[x,y]/(x^2,y^2,xy)$. Notice that every element has a representative of the form $a+bx+cy$. If $a=0$, this is a zero-divisor. If $a\ne 0$, then $a^{-1}-a^{-2}bx-a^{-2}cy$ is an inverse. So this ring satisfies the hypotheses of the question. Can you exhibit infinitely many ideals of this ring?
$R$ is also an example of an infinite commutative ring with infinitely many zero divisors.
What should be correct way to solve it?
Proving the given statement (with the finiteness conditon) would be a duplicate question of Every nonzero element in a finite ring is either a unit or a zero divisor, so I will direct you to the very good solutions that already exist there.
What happens if we drop "finite" condition on R?
$\Bbb Z$ is a commutative ring with unity which has exactly two units and (in my convention) only one zero divisor, and everything else is neither unit nor zero divisor. So deleting the word finite pretty much wrecks the statement.
I know I am wrong but I thought $R$ to be an integral domain.
Well my example just now was an integral domain, but no, being a domain has nothing to do with it. The ring $F[x]/(x^2)$ for an infinite field $F$ is an infinite commutative ring with identity which isn't a domain and yet is partitioned between units and zero divisors.
So you can't just delete finite, but you can easily replace it with far more general adjectives.$^\ast$ Being finite is in no way necessary for elements to be partitioned between units and zero divisors. There are huge classes of infinite rings that have that property.
Probably the next simplest generalization of this question is to prove that for any right Artinian ring $R$, every element is a unit or zero divisor (I count $0$ among zero divisors.) Finite rings are of course left and right Artinian. But now you have, for example, every $n\times n$ matrix ring over a field, and every quotient of a polynomial ring over a field as examples beyond finite rings.
Actually you can go to something even more general called a strongly $\pi$ regular ring$^{\ast\ast}$. There is a simple proof for both claims at this question: Rings whose elements are partitioned between units and zero-divisors. and here.$^{\ast\ast\ast}$
$^\ast$ You can simply delete the word commutative, though.
$^{\ast\ast}$ A strongly $\pi$-regular ring is one which has the descending chain condition on chains of the form $xR\supseteq x^2R\supseteq x^3R\supseteq\ldots$
$^{\ast\ast\ast}$ There is also a related (but more oddly worded) post about this.
Best Answer
In a finite commutative ring with unity, every element is either a unit or a zero-divisor. Indeed, let $a\in R$ and consider the map on $R$ given by $x \mapsto ax$. If this map is injective then it has to be surjective, because $R$ is finite. Hence, $1=ax$ for some $x\in R$ and $a$ is a unit. If the map is not injective then there are $u,v\in R$, with $u\ne v$, such that $au=av$. But then $a(u-v)=0$ and $u-v\ne0$ and so $a$ is a zero divisor.
For the noncommutative case, see this answer.