我的用户模型中有列inviter
。我想从链接中获取参数并将其保存在 cookie 中。例如,从此链接:
domain.com/?ref=5
我想保存到 cookie 号码?ref=**5**
并且当用户去注册时,用户不需要在表单中写推荐号码,因为它已经在 cookie 中。
<%= form_for(@user) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= f.label :name,'Your name'%>
<%= f.text_field :name, class: 'form-control' %>
<%= f.label :email,'Email' %>
<%= f.email_field :email, class: 'form-control' %>
<%= f.label :invite, 'Number who invited you' %>
<%= f.text_field :invite, class: 'form-control' %>
<%= f.label :password, 'password' %>
<%= f.password_field :password, class: 'form-control' %>
<%= f.label :password_confirmation ,'password confirmation' %>
<%= f.password_field :password_confirmation, class: 'form-control' %>
<br>
<br>
<div class="textc">
<%= f.submit yield(:button_text), class: "formbut" %>
</div>
<% end %>
邀请号码将使用?ref=**5**
并注册新用户。