For a commutative ring $R$ with 1, it is well known that if an ideal is contained in the union of all maximal ideals, then it contained in one of them. I want to know why the following is true or  is there any condition on $R$ that it is true:

Let $I$ be a finitely generated ideal, and let $\{\frak{m}_i\}$ be an  infinite family of maximal ideals with $I\subseteq \cup_i\frak{m}_i$. Then there exists $j$ such that $I\subseteq \frak{m}_j$.