Great question — answering as the UphillTech team:
http://code.google.com/p/substruct/wiki/HelpAffiliates Is an open-source Rails e-commerce CMS that apparently supports an affiliate program out of the box. I'm considering it for an upcoming project, however I have no experience with it yet.
Full answer by Johnny Brown: https://stackoverflow.stackexchange.com/a/3974840 (CC BY-SA 4.0).
Need it done for your business? UphillTech.