In an algebraic number theory course, my lecturer said that any ideal of $\mathcal O_K$, where $K$ is a quadratic number field, is generated by at most two elements. I am wondering why this is. When $K$ is as above, $\mathcal O_K$ is a free $\mathbb Z$-module of rank 2, so I want to say that if an ideal was generated by more than two elements and couldn't be "reduced" to a form that is generated by two elements, then it would be a free $\mathbb Z$-module of rank $>2$, a contradiction.
I am wondering if this logic is justified, in particular:
Is the minimal number of generators of an ideal of $\mathcal O_K$ equal to the rank of the ideal as a free $\mathbb Z$-module?
(If the result is true, this would also give a solution to a generalised result about non-quadratic number fields $K$.)
I can't think of how to start with this, as I have trouble thinking about non-principal ideals.
(My lecturer also mentioned that for any $K$, an ideal of $\mathcal O_K$ will still be minimally generated by at most two generators, but that this is a deep theorem. If you can give me a reference to where this is proved I would be very grateful, though this is not my main question.)