Every finitely generated flat module over a ring with finitely many 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 $V(p)$, 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 (Reasoning: 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 right?). Am I right ?
I am asking this simple question because I read this great answer here
https://mathoverflow.net/a/33574/3333
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 ?
Edit2: 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 ?
 A: There are two questions here. First of all, yes, the argument is fine; secondly, yes, there are rings with finitely many minimal primes, but infinitely many associated primes. So all together, the criterion is slightly more general than the one by Raynaud-Gruson mentioned in the question, but the proof is much easier. It also admits a further generalisation (very slightly) as shown below.
First, the construction of a ring with finitely many minimal primes but infinitely many associated primes. It is obviously inspired by the ring $k[t,x]/(t^2,tx)$ which corresponds to the line with an embedded point in the origin, just that we take infinitely many embedded points. Of course, we have to leave world of polynomials for that.
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.
Then $A = H[t]/(t^2,tf)$ is such an example.
The nilradical of $A$ is the prime ideal $(t)$. Thus, $(t)$ is the unique minimal prime.
However, for each root $\alpha\in\mathbb{C}$ of $f$, we easily see that $(t,z-\alpha) = \mathrm{ann}_{A}(t(z-\alpha)^{-1}f)$ is an associated prime of $A$. By assumption, there are infinitely many roots, hence infinitely many associated primes.
To give a complement to the arguments given in the question and the comments on MSE, here is the generalisation to schemes (using the same arguments).

Let $X$ be a scheme with open connected components, each of which is a finite union of maximal irreducible components.
  Then every flat quasi-coherent $\mathcal{O}_X$-module of pointwise finite rank is Zariski-locally trivial.

This is a local question and we assumed the connected components to be open, so we may just assume that $X$ is connected and show that the rank is constant then.
Let $F$ be a quasi-coherent flat $\mathcal{O}_X$-module with $F_x$ finitely generated for each $x\in X$.
Let $\eta_1,\eta_2,\dots \eta_s\in X$ be the generic points of the maximal irreducible components $X_i := \{\eta_i\}^{-}$, $i = 1,2,\dots s$.
We first have to show that the rank of $F$ is constant on each $X_i$.
The basic thing to note is: if $y\leadsto x$ is a specialisation, i.e., $x\in\{y\}^{-}$, then $\mathcal{O}_{X,y}$ is a localisation of $\mathcal{O}_{X,x}$ and with respect to this structure we have $F_{y} = F_{x}\otimes_{\mathcal{O}_{X,x}}\mathcal{O}_{X,y}$.
Therefore, if $F_x$ is a free $\mathcal{O}_{X,x}$-module, then $F_y$ is a free $\mathcal{O}_{X,y}$-module of the same rank.
By definition, each $x\in X_i$ is a specialisation of $\eta_i$ and so the rank is constant on each maximal irreducible component.
To show that the rank is constant on our connected scheme $X$ we consider the subsets
$V_k := \{x\in X\mid \mathrm{rk}_{\mathcal{O}_{X,x}}(F_x) = k\}$
disjointly covering $X$ as $k\geq 0$. 
Since the rank is constant on maximal irreducible components, each $V_k$ is a union of such.
But there are only finitely many maximal irreducible components, so there are only finitely many nonempty $V_k$ and all of them are closed, hence, also open.
Since $X$ is connected, the only possibility for this to happen is when $X = V_k$ for some $k\geq 0$, i.e., if the rank is $k$ at every point.
A: Over a general ring (not necessarily commutative), every finitely presented flat module is projective.
So, one simple condition on the ring that gives you what you want is that every finitely generated module is finitely presented. Of course, these are just the (left) Noetherian rings.
