Bring a large pot of water to a strong boil. Add about a tablespoon of salt for every 2 quarts of water. Add the pasta and boil, uncovered, until the pasta is al dente—edible but still a little firm.
Drain the pasta through a colander. Toss with a little olive oil so the pasta does not stick together while you make the sauce. Pour a tablespoon or so of olive oil into a large sauté pan on medium-high to heat.
When the oil is hot, add the bulk sausage or ground meat. Do not crowd the pan (work in batches if needed). Break up any large chunks of sausage as it cooks. Brown well. Don't stir that often or it will be more difficult for the meat to brown. If you are using ground beef or pork instead of sausage, add a little salt.
When the meat is mostly browned, add the onions and stir well to combine. Sauté everything until the onions are translucent and beginning to brown, about 4-5 minutes. Add the garlic, rosemary or basil, Italian seasoning and red pepper flakes and stir to combine.
Cook 1 minute, then add the tomato sauce and stir well. Bring to a simmer. Preheat the oven to 350°F. Spread a thin layer of sauce in the bottom of a 9x13-inch casserole pan, then dot the surface with half the ricotta cheese.
Ladle in some sauce with the pasta, mix it well and add the pasta into the casserole. Pour the rest of the sauce over the pasta, dot the remaining ricotta cheese over the pasta, and sprinkle on top both the mozzarella and the Parmesan cheese.
Bake in the oven until the top is nicely browned, about 20 minutes.