Ramban on Genesis 48:7
The plain explanation is that Jacob spoke in an apologetic tone pleading with Joseph not to be angry with him for this last request to bury him in the Cave of Machpelah on the grounds that he had not buried his mother there, as he had done for Leah. For this reason, he said to him that she had died in the land of Canaan and that she had not been buried outside the Holy Land as would be the case for Jacob should his remains be left in Egypt.
Rachel, he explained, had died on the journey suddenly and he had not been able to bury her in the family tomb. For how could he have left his children and cattle on the way and have gone quickly to the Cave of Machpelah? Where were the embalmers and medicaments to embalm her?
This is the implication of the word alayei - unto me or upon me. Though the Cave of Machpelah was not more than half a day's journey from where Rachel died, Jacob was heavily burdened with cattle and members of his household and would only have been able to reach there in a number of days. Indeed it took him many days until he reached his father's home.
(ד) בדרך בעוד כברת ארץ לבא אפרתה תכף כשנסעתי מאותו המקום שהיה דבר האל יתברך אלי בעודי בדרך אפרת. וכל כך גברה עלי טרדתי ואבלותי שלא עצרתי כח להוליכ' לבית קברות בית לחם ואין ספק כי מאז היה לבי חלל בקרבי ...
(4) בדרך בעוד כברת ארץ לבא אפרתה, immediately after G’d finished speaking to me before I had even arrived at Beyt Lechem, ואקברה שם בדרך אפרת, and I had to bury her there on the route to Efrat; I was so overcome by grief at the time that I did not even have the strength to transport her remains to the burial grounds in Beyt Lechem. There is no doubt that ever since her death my heart was so full of grief...
Rachel died suddenly and I could not bury her in the Cave as I buried Leah. He mentioned this to Joseph that he should not be angry for asking him for something which he had not done on behalf of his mother.
(ג) אקברה שם. וְלֹא הוֹלַכְתִּיהָ אֲפִלּוּ לְבֵית לֶחֶם לְהַכְנִיסָהּ לָאָרֶץ, וְיָדַעְתִּי שֶׁיֵּשׁ בְּלִבְּךָ עָלַי; אֲבָל דַּע לְךָ שֶׁעַל פִּי הַדִּבּוּר קְבַרְתִּיהָ שָׁם, שֶׁתְּהֵא לְעֶזְרָה לְבָנֶיהָ כְּשֶׁיַּגְלֶה אוֹתָם נְבוּזַרְאֲדָן, וְהָיוּ עוֹבְרִים דֶּרֶךְ שָׁם, יוֹצֵאת רָחֵל עַל קִבְרָהּ וּבוֹכָה וּמְבַקֶּשֶׁת עֲלֵיהֶם רַחֲמִים, שֶׁנֶּאֱמַר קוֹל בְּרָמָה נִשְׁמָע וְגוֹ' וְהַקָּבָּ"ה מְשִׁיבָהּ יֵשׁ שָׂכָר לִפְעֻלָּתֵךְ נְאֻם ה' וְשָׁבוּ בָנִים לִגְבוּלָם (ירמיהו ל"א).
(3) ואקברה שם AND I BURIED HERE THERE and did not carry her even the short distance to Bethlehem to bring her into a city. I know that in your heart you feel some resentment against me. Know, however, that I buried her there by the command of God”. And the future proved that God had commanded him to do this in order that she might help her children when Nebuzaradan would take them into captivity. For when they were passing along that road, Rachel came forth from her grave and stood by her tomb weeping and beseeching mercy for them, as it is said, (Jeremiah 31:15) “A voice is heard in Rama, [the sound of weeping … Rachel weeping for her children]”, and the Holy One, blessed be He, replied to her (v. 16) “Refrain from weeping, and your eyes from tears; There is a reward for your work, says the Eternal. (v. 17) they shall come back from their enemy's land. There is hope for the future, says the Eternal, for your children will return to their own border”.
Ramban on Genesis 48:7
At any rate there should be some allusion in the text to this idea (of Rashi's). Perhaps to this the text alludes when it repeats, "Rachel died unto me on the way...and I buried her there on the way" implying on the way that her children were destined to pass did she die and there she was buried for their sake, since she had not actually died "on the way" but at 'Ramah' which is a town in the land of Benjamin and there she was buried.
But what the text meant to suggest was that she was buried at a spot where her descendants were destined to pass, when they were on the way going in to exile. The text does not, however, explicitly refer to future events, but merely alludes to them.