Let $_RM \in R$-Mod for a unital ring $R$. Show that the following two conditions on $_RM$ are equivalent
(a) $_RM$ is finitely generated;
(b) for every family $\{_RM_i : i \in I \} \subseteq R$-Mod and each epimorphism $f: \bigoplus_{i \in I}$$ _RM_i \to$ $_RM$ there exists a finite subset $J \subseteq I$ such that the composition
$\bigoplus_{j \in J}$$ _RM_j \overset{i_J}{\longrightarrow} \bigoplus_{i \in I}$$ _RM_i$ $\overset{f}{\longrightarrow}$$_RM$
is surjective (where $i_J$ denotes the canonical monomorphism).
This question was given to me in class, and I can show that (a) $\Rightarrow$ (b), but I'm struggling with (b) $\Rightarrow$ (a). So for each $(m_j) \in\bigoplus_{j \in J}$$ _RM_j$, its image under $i_J$ will have only finitely many non-zero entries, less than $|J|$, and for each $m \in$$ _RM$, $m = f(i_J(m_j))$ but I don't know how to show that this implies there are finitely many generators for $_RM$.
Any hints would be appreciated!
For (b) implies (a) take a set of generators $m_i$ for $M$, indexed by $I$. Then define an epimorphism $\bigoplus _{i\in I} R\to M$ by sending the element with $0$'s in every component except for a $1$ in the $i$-th component to $m_i$.
Now use the hypothesis to see that a finite subset of the $m_i$ generate $M$.