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 http://mathoverflow.net/a/33574/3333https://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 ?