It would probably be easiest to send data only from Ruby (by the way, which Ruby library are you using?) since the link and account creation must be sent server-side.
You will have to choose a distinct_id that will identify a user through this entire process. The easiest way is to just use the invitee's e-mail address. This has the additional benefit of being able to track other events and "people" data with that e-mail and associate it with the right user.
The only tricky part is step 2. You will need to generate a link that looks like
http://api.mixpanel.com/track/?data=...&ip=1&redirect=http://www.your-site.com/invitation
to put inside the email as the invitation link.
See the docs for more info about the redirect parameter.