Rank of free submodules of a free module over a commutative ring. Free modules over a commutative ring $R$ with $1$ have well-defined rank. 

I have been wondering if there is a ring $R$ such that there are free modules $M'\subset M$ with $\operatorname{rank}(M')>\operatorname{rank}(M)$ for a while, but can't come up with examples or a proof of the contrary in general. 

All I know is that this never happens if $R$ is a domain, since you can consider $M'$ and $M$ as vector spaces over the fraction field of $R$.
 A: Lemma
One way to see why free submodules of free modules over a commutative ring have to have lesser or equal rank uses this lemma. The lemma is shown here, that surjections of finitely generated modules over commutative rings are necessarily isomorphisms.
If $R^m$ were isomorphic to a submodule of $R^n$ and $m>n$, you would easily be able to construct a projection of that submodule onto $R^n$ which would then necesarily be an isomorphism, but that is impossible since we have decided ranks of f.g. free modules are well-defined for commutative rings.

Bonus (=ignorable)
Rings which have well defined ranks for their finitely generated free modules are said to have the IBN property. This property is: "If $R^n$ and $R^m$ are isomorphic as right $R$ modules, then $m=n$."
The proof that a commutative ring $R$ has the IBN is pretty easy if you can make a few jumps. First of all, after picking a basis for $R^n$ and $R^m$, one can see this amounts to finding an $n\times m$ matrix $A$ and an $m\times n$ matrix $B$, both over $R$, such that $AB=I_n$ and $BA=I_m$. The second observation is that we can pick a maximal ideal $M$ of $R$ and project from $R$ onto $R/M$, a field. But if you apply this projection to the entries of $A$ and $B$, you wind up with two matrices which are mutually inverse over a field: but that implies $m=n$ since we know dimension is well-defined for vector spaces.
There are examples for rings in general, but not for commutative rings. The familiar example for rings with ranks which aren't well defined are that of full linear rings. 
Take $R$ to be the ring of transformations of a countable infinite dimensional vector space. It's not hard to show that $R\cong R^2$ as $R$ modules, and hence by induction $R\cong R^n$ for any $n\in \Bbb N$, and then $R^n\cong R^m$ for any positive integers $n,m$.
If by "rank" you are thinking of the $n$ and $m$ above, then this example shows that "rank" of a free module isn't always well defined.
Moreover, if this didn't convince you already, take $R^2$ and look at the submodule $R\times \{0\}$. The submodule is still isomorphic to $R^m$ for whatever positive integer $m$ you like. 
