Cut the potatoes and onion into very thin slices. Preheat oven to Gas Mark 6, 200°C, fan180°C. Lay the filo pastry onto a clean worktop and cut sheets in half. Brush a 20cm (8in) loose-bottomed, fluted flan tin with the oil, then lay a sheet of pastry in the base, allowing a little to hang over the edges. Brush lightly with oil, continue to layer up until most of the pastry has been used. Leave 4-5 pieces for the top.
Add layers of potato, onion, ricotta and spinach, seasoning and sprinkling with crushed garlic and nutmeg as you go. Bring pastry up over the filling, scrunching it on top. Add remaining pastry sheets also scrunched up. Drizzle with a little more oil.
Bake the pie for 20 minutes, then lower oven to Gas Mark 4, 180°C, fan160°C. Cook for another hour until potatoes are tender. Serve hot or cold.