我正在使用devise_invitable
创建访客帐户来访问文档。访问文档时,访客可以单击升级按钮,升级为完整帐户。单击升级按钮即表示接受devise_invitable
邀请。
以前工作:不再工作。
环境:
- rails 4.2.3(最近升级)
- 设计 3.4.1
- 设计邀请 1.3.6
我为生成升级链接的来宾用户使用了部分标头:
<% @invite_link = accept_user_invitation_url(invitation_token: @invite_token) %>
<%= link_to "Upgrade", @invite_link, class: "btn btn-danger btn-lg" %>
@invite_token
创建如下:
user = current_user
user.invite! do |u|
u.skip_invitation = true
end
@invite_token = user.raw_invitation_token
所以link_to
helper 生成类似的东西:https://myapp/users/invitation/accept?invitation_token=vv_JqeFDLfyX65tx2KhR
除非我点击链接,否则我会:https://myapp/users/sign_in
带有错误消息:The invitation token provided is not valid!
日志报告类似于:
Started GET "/users/invitation/accept?invitation_token=vv_JqeFDLfyX65tx2KhR" for 31.15.32.222 at 2015-10-15 19:18:34 +1100
Processing by Devise::InvitationsController#edit as HTML
Parameters: {"invitation_token"=>"vv_JqeFDLfyX65tx2KhR"}
User Load (5.9ms) SELECT "users".* FROM "users" WHERE "users"."invitation_token" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["invitation_token", "ea9be9890c684e13ece13ec02f89bade81fcd3ac1fb982db72d8f8561d0cf289"]]
Redirected to https://myapp/
Filter chain halted as :resource_from_invitation_token rendered or redirected
Completed 302 Found in 53ms (ActiveRecord: 5.9ms)
Started GET "/" for 31.15.32.222 at 2015-10-15 19:49:52 +1100
Processing by PagesController#index as HTML
Redirected to https://myapp/users/sign_in
Completed 302 Found in 11ms (ActiveRecord: 0.0ms)
我能够通过 Rails 控制台完成这项工作。
如果我并行运行rails 控制台,我可以逐步完成上述步骤并生成一个按预期工作的accept_invitation 链接(即它提示用户为完整帐户设置密码)。
注意:raw_invitation_token
rails 控制台会话中的不同。
我错过了什么?