I am trying to write a "viral" pre-beta invitation application as one can see on usehipster.com or fork.ly.
Basically, the future tester:
1.) enters his email
2.) is redirected to a view (a coming_soon page)
3.) receive a link like this one : "http://localhost:3000/?referred_to=the tester's invitation id" displayed in the view.
4.) and receive an email with the same link.
If I understand it well, the "tester's invitation id" acts as a token in order to track from which testers the invitation come from.
My questions:
1.) How can I generate the id in the link? I cannot use before_create cause the invitation id is not already set up when a tester registered.
I tried this:
in the invitation controller
def coming_soon
@invitation = Invitation.last
end
in views/invitations/coming_soon.html.erb
...
Copy and paste the following link to share wherever you want!</p>
<%= text_field_tag 'code', root_url + "?reffered_by=" + @invitation.id.to_s %>
Do you think they do like this?
2.) Why there is a question mark in the link? (or something like ?reffered_by= why not just root_url/@invitation.id.to_s) This is something related to the routes? is it a get method?
Thanks for your help!