Every finitely generated flat module over a ring with a finite number of minimal primes is projective Over a commutative ring $R$, a finite type locally free (weak sense) module for which the rank function is locally constant is projective.
If we notice that for each minimal prime $p$ of the ring, the rank function is constant on the adherence of $p$ in the Zariski topology (because if $p\subset q$ the rank at $p$ is equals to the rank at $q$) on finite locally free (weak sense) modules, then if the ring has only a finite number of minimal primes, the rank function is always locally constant on finite flat modules. Am I right ?
Edit 2: Answering a request of Ben the detailed reasoning is the following:
 The image of the rank function is finite in $\mathbb{N}$. Every reciprocal image of an integer $n$ is a finite union of closed sets like the $V(p)$. So it is a closed set. The disjoint union of these closed sets is the whole spectrum. Each one of them is therefore open.
I am asking this simple question because I read this great answer here where an important paper of Raynaud-Gruson is mentioned. It gives amongst a lot of generalizations the simple criteria that if $R$ has a finite number of associated primes then without any other hypothesis on $R$ every f.g. flat modules is actually projective. My reasoning above seems quite simple and gets a slightly more general result, but perhaps I am wrong ?
Edit: since nobody answered my question I dug around but I did not find any reference to this simple criteria. I only found the criteria about the finiteness of the number of associated primes. Is it equivalent ? Is there a counterexample with an infinite number of embedded primes but a finite number of minimal (isolated) primes ? 
Edit 3: the answer is here.
 A: Upon request, I repost my MathOverflow answer (c.f. MO/218737).
There are two questions here, namely, whether the argument given in the question is okay, and whether the criterion really is more general than the one by Raynaud-Gruson. The answer to both questions is yes. The following holds:

Let $A$ be a commutative with unity and $M$ a flat finitely generated $A$-module. Then the rank function $\mathrm{Spec}(A)\to\mathbb{N}_0$, $\mathfrak{p}\mapsto \mathrm{rk}_{A_\mathfrak{p}}(M_{\mathfrak{p}})$, is constant on all irreducible components of $\mathrm{Spec}(A)$. In particular, if $\mathrm{Spec}(A)$ has finitely many maximal irreducible components (i.e., if $A$ has finitely many minimal prime ideals), then the rank function is locally constant, hence $M$ is projective.

The (very nice and short) proof was given by the OP in the question text and in a comment. (With the same arguments, one can further generalise this to schemes; see loc. cit.)
The criterion by Raynaud-Gruson requires finitely many associated primes, so to be sure that the above criterion is more general, we need an example of a ring with finitely many minimal, but infinitely many associated prime ideals.
The following example has a single minimal prime ideal, but infinitely many associated prime ideals. Picture it as a line with infinitely many embedded points. (Just as $k[x,t]/(t^2,xt)$ has associated primes $(t)$, the unique minimal one, and $(x,t)$, the "embedded point".)
Let $H$ be the ring of holomorphic functions on the complex line $\mathbb{C}$ (with coordinate $z$) and $f\in H$ a non-trivial holomorphic function with infinitely many zeros (e.g., $f(z) = \sin(z)$). We consider the ring $A:=H[t]/(t^2,tf)$.
Since $A/(t)\cong H$ is an integral domain, the ideal $(t)$ is prime. On the other hand, this ideal happens to be the nilradical of $A$, which is the intersection of all prime ideals; thus, $(t)$ is the only minimal prime.
However, for each root $\alpha\in\mathbb{C}$ of $f$ we recognise the associated prime ideal $(t,z-\alpha)\subset A$, so there are infinitely many of them.
In fact, if $g\in H$ is the unique entire function with $(z-\alpha)g = f$, then it is easy to see that $(t,z-\alpha) = \mathrm{ann}_{A}(tg)$.
