Preheat oven to 180°C (356°F).
Cook your gnocchi according to packet instructions. Once cooked, drain and set aside.
In a medium sized saucepan, heat the oil. Once hot, add the brown onion. Fry until the onions are starting to soften and go lightly brown.
Add the chorizo and cook until crisp. If you are using fresh chorizo break it into smaller pieces, if you are using dried chorizo, make sure you cut the chorizo into small pieces before frying.
Add the minced garlic and saute for about 1 minute. Be careful not to burn your garlic.
Next, add the tomato puree (tomato passata), cream, stock, anchovies (if using), basil, oregano, and sugar. Mix well. Bring the liquid to a simmer and then reduce heat to low medium.
Mix through the fresh ricotta cheese, breaking it up into smaller pieces if necessary. Then add the green onions, and salt and pepper to taste.
Mix through the cooked and drained gnocchi.
Transfer mixture into a casserole dish, making sure the top sites flat.
Top with grated cheese. Then place in preheated oven and bake for 10 to 15 minutes or until the top is golden brown. Once baked, remove from oven and allow to cool.