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. Am I right ?
I am asking this simple question because I read this great answer here http://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 ?
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 2: after the answer of Konstantin, I want to emphasize that my question is not about finding any simple condition on the ring. I just want to know if the simple condition I found is sufficient and my elementary reasoning correct. My title was misleading. I edited it.