When the verse "And upon those who are able to fast, a ransom of feeding a poor person" [Baqarah 2:184] was revealed, anyone who wished could break the fast and pay the ransom, until the verse that followed was revealed and abrogated it.
لما نزلت: {وعلى الذين يطيقونه فدية طعام مسكين} كان من أراد أن يفطر ويفتدي، حتى نزلت الآية التي بعدها فنسختها.
Bukhari narrated it in tafsir (4507), and Muslim narrated it in the Book of Fasting (149:1145), both of them from Qutayba bin Saeed, who said, Bakr bin Mudar narrated to us, from Amr bin Harith, from Bukayr bin Abdullah, from Yazid the freed slave of Salama, from Salama bin Akwa, and he related it.The meaning of the hadith is that when the words of Allah were revealed, "and those who are able to do it only with hardship shall pay a fidya, the feeding of a poor person", whoever wished could fast, and whoever wished could feed a poor person instead. Then Allah revealed the other verse, which is His saying, "The month of Ramadan in which the Quran was revealed", up to His saying, "So whoever among you is present that month, let him fast it".So Allah established the obligation of fasting for the resident who is in good health, granted a concession from it for the sick and the traveler, and confirmed feeding the poor as an obligation for the elderly person who is unable to fast.