我有一个使用 Devise 3.2.2 的 Rails 4 应用程序:confirmable
,并且遇到了发送无效确认令牌的问题,但只是第一次。重新发送确认令牌后,该链接有效。
相关路线:
devise_for :users, skip: [:sessions, :passwords, :confirmations, :unlocks, :registrations, :invitations]
as :user do
...
# joining
get '/register' => 'devise/registrations#new', as: 'new_user_registration'
post '/register' => 'devise/registrations#create', as: 'user_registration'
...
end
...以及有问题的邮件模板:
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @token) %></p>
据我所知,一切都是相当标准的票价,而且它只在最初创建而不是重新发送时失败的事实相当令人困惑。
- 更新 -
单击链接时,我在开发日志中得到以下信息:
Started GET "/account/confirm?confirmation_token=3bQP-EvYJPv74s9AMz63" for 127.0.0.1 at 2014-02-07 12:26:10 -0500
Processing by Users::ConfirmationsController#show as HTML
Parameters: {"confirmation_token"=>"3bQP-EvYJPv74s9AMz63"}
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."confirmation_token" = 'e191b48746f15014beb32073f08de3c7aa13a2282216f089fa71d083901b3dca' ORDER BY "users"."id" ASC LIMIT 1
Rendered devise/shared/_links.slim (1.2ms)
Rendered devise/confirmations/new.html.slim within layouts/devise (7.0ms)
Rendered layouts/_jquery.slim (1.0ms)
Completed 200 OK in 32ms (Views: 23.4ms | ActiveRecord: 0.4ms)
引用的控制器是:
class Users::ConfirmationsController < Devise::ConfirmationsController
protected
def after_confirmation_path_for(resource_name, resource)
if signed_in?
signed_in_root_path(resource)
else
new_session_path(resource_name, email: resource.email)
end
end
end
-- 更新 2 --
以下是整个注册过程的日志要点: https ://gist.github.com/jbender/bbe079c2dd3fa2d1e664