我正在尝试编写一个“病毒式”预测试邀请应用程序,正如人们可以在usehipster.com或 fork.ly上看到的那样。
基本上,未来的测试人员:
1.) 输入他的电子邮件
2.) 被重定向到一个视图(一个coming_soon 页面)
3.) 收到一个类似这样的链接:“http://localhost:3000/?referred_to= the tester's invite id ”显示在视图中。
4.) 并收到一封带有相同链接的电子邮件。
如果我理解得很好,“测试人员的邀请 id”充当令牌,以跟踪邀请来自哪些测试人员。
我的问题:
1.) 如何在链接中生成 id?我不能使用 before_create,因为在测试人员注册时尚未设置邀请 ID。
我试过这个:
在邀请控制器中
def coming_soon
@invitation = Invitation.last
end
在意见/邀请/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 %>
你认为他们会这样做吗?
2.) 为什么链接中有问号?(或类似 ?reffered_by= 为什么不只是 root_url/@invitation.id.to_s) 这与路线有关?它是一个get方法吗?
谢谢你的帮助!