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.)
An ideal is a $\mathbb{Z}$-submodule. It is possible for two elements in $\mathbb{Z}^2$ to generate a proper submodule, but it is not possible for three elements to be linearly independent over $\mathbb{Z}$ (we can always find a nontrivial linear combination that is $0$). Furthermore, any submodule is free and therefore has a linearly independent generating set. Thus an ideal has a minimal generating set with at most two elements because in fact it is additively generated over $\mathbb{Z}$ by a set with at most two elements.
This does not rule out a priori that there exists a minimal generating set with more than two elements, in the sense that none of them could be omitted and have the set still generate the ideal. That would just be the "wrong" generating set, and we could pick a smaller, completely different one.
Note this doesn't answer the main question.