Wash the eggplants and cut into slices. Heat a grill pan or frying pan and toast the eggplants until golden brown on both sides.
Peel the garlic and crush it with the flat side of a knife. Heat the oil in a pan and cook the tomatoes and garlic for about 20 minutes on low heat. Season with pepper and salt. Add the eggplant.
Cook the pasta al dente in boiling water with some salt according to the instructions on the package. Drain and keep the cooking liquid.
Pluck the leaves of the sprigs of basil and add the leaves just before serving in the sauce with a spatula. Pour the pasta with 2 tablespoons of cooking liquid into the sauce. Pour the pasta into the plates and crumble the ricotta on top of it.