I understand that the Rails framework can be used to generate PHP code
That's not generally true. I suppose somebody somewhere may have made this happen, but their mental health problems would not be insignificant.
Ruby and PHP both appeared at about the same time, according to Wikipedia (here and here). Ruby was a fairly general-purpose scripting language that erupted into the Web World with the advent of Rails in 2004, whereas AFAIK, PHP was designed for web development.