Which is preferable, to go to graduate school at same school as undergrad or to go to a lower-ranked school?
I've heard from people that generally, it's a bad idea to go to the same school as your undergrad to get your graduate education. 


The word "generally" is commonly used in two rather different senses.  The first sense is "typically", "most often".  The second sense -- perhaps more common in mathematical and scientific writing -- is "always", or "in the largest possible scope which might be applied".  The quoted advice is valid if "generally" is construed in the former sense, not the latter.  To briefly explain: on the one hand, there are advantages to acquiring a diversity of experience.  "Great University X" will do its business in a way which is slightly different from "Great University Y".  Experiencing this is very valuable, because if you stay in academia you will probably be affiliated with several more universities, different from each of these.  If all of your student experience is at a single place, you will have subconsciously internalized the universality of your experience, and you'll be in for a rude awakening when you learn that what is obviously best to you is not the practice in your new environment.  Then too, by going to different great universities, you meet different great people (many of whom will know each other and will be in transit to/from other great universities), both students and faculty.  This is also very valuable.

On the other hand, there are situations where it is most advantageous to stay where you are.  For instance there are sometimes personal, family or financial considerations.  Even neglecting these, there are times that the university you attended as an undergraduate is truly the uniquely best option for you to continue your studies, or the best option among those available to you.  If you are an undergraduate at UCLA, if you want to study analysis, and if you did not get admitted to Berkeley, MIT, Chicago, Princeton or Stanford, then staying where you are sounds like an excellent (perhaps optimal) choice academically.  If you've already done successful research with a top faculty member at your current program and you truly want to continue that research most of all: yes, think seriously about staying right where you are.  

The other answer says that graduate school rankings is "a little ridiculous".  While I don't really disagree, let me try to put a finer point on that: grad school rankings are ridiculous if you take them too seriously, and especially if you regard them as a strict linear ranking.  It does not matter that US News and World Report currently thinks that MIT is the best mathematics department in the US whereas in past years it used to think it was some combination of Harvard / Princeton / Berkeley.  It would be more honest and more helpful if they simply recorded that these departments and several others (Chicago, Stanford,...) are in the uppermost echelon of graduate programs in mathematics.  Asking whether Harvard is better than Stanford is ridiculous: it depends upon what you're studying.  (If you want to study analysis, don't go to Harvard unless you know you want to work with the one faculty member there who does that.)  

Students should be thinking of departments in terms of echelons.  Within a given echelon, ranking is not helpful.  However, barring some truly exceptional circumstances you want to go to a program in the top echelon that accepts you.  As a corollary to this: if your undergraduate institution is in the top 10, and every other program you've gotten into isn't in the top 30, then yes, I think you should stay where you are, unless you have a very good reason to go to a lower-ranked department (best reason: there is a superstar there that has agreed to work with you).  

Finally though I have to say that I find it slightly odd that the OP has apparently gone to a top department, been admitted as a student to that top department, but not at any other department of comparable quality.  That suggests to me that her application is not as strong as it could be, as those who know her in real life apparently value her more highly.