[英]ActionController::UnknownFormat Devise Confirmation
每當我有一個尚未確認其帳戶的用戶時,如果在輸入正確的電子郵件地址后單擊“重新發送確認說明”,則會成功發送一封電子郵件(無論如何仍在開發中),然后會出現以下錯誤消息:
ActionController::UnknownFormat at /users/confirmation.user
ActionController::UnknownFormat
在此URL:
http://localhost:3000/users/confirmation.user
這是我的ConfirmationsController
class ConfirmationsController < Devise::ConfirmationsController
private
def after_confirmation_path_for(resource_name, resource)
new_session_path(resource_name)
end
end
這是整個事件的日志:
Started POST "/users/confirmation.user" for 127.0.0.1 at 2014-12-28 19:23:23 -0500
Processing by ConfirmationsController#create as
Parameters: {"utf8"=>"✓", "authenticity_token"=>"SaKoS0Xo3PEkPLDRGt0s1dDsFL3sWIGAS6TZ69bhF4E=", "user"=>{"email"=>"xyz@test.com"}, "commit"=>"Resend confirmation instructions"}
User Load (3.6ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'xyz@test.com' ORDER BY "users"."id" ASC LIMIT 1
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."confirmation_token" = '03f1df6d19e7ca7f5b3f0789e159ba3b31b24895fffc6124def25467e901b5df' ORDER BY "users"."id" ASC LIMIT 1
(1.5ms) BEGIN
SQL (14.2ms) UPDATE "users" SET "confirmation_sent_at" = $1, "confirmation_token" = $2, "updated_at" = $3 WHERE "users"."id" = 4 [["confirmation_sent_at", "2014-12-29 00:23:23.286698"], ["confirmation_token", "03f1df6d19e7ca7f5b3f0789e159ba3b31b24895fffc6124def25467e901b5df"], ["updated_at", "2014-12-29 00:23:23.296387"]]
(1.5ms) COMMIT
Rendered devise/mailer/confirmation_instructions.html.erb (0.8ms)
Devise::Mailer#confirmation_instructions: processed outbound mail in 20.1ms
Sent mail to xyz@test.com (39.6ms)
Date: Sun, 28 Dec 2014 19:23:23 -0500
From: noreply@myapp
Reply-To: noreply@myapp
To: xyz@test.com
Message-ID: <54a09efb589ec_12f63fc655865be02817a@myputer.local.mail>
Subject: Welcome to My App! Please confirm your email address
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<center><img alt="Logo" height="50" src="http://someurl.com/assets/logo.png" width="153" /></center>
<p>Welcome to My App, xyz@test.com! Please confirm your email address by clicking the link below:</p>
<p><a href="http://localhost:3000/users/confirmation?confirmation_token=EXJkB4sZxP18m2sVQyBQ">Confirm my account</a></p>
<p>Once you confirm, you are welcomed to join the community by sharing, reading and commenting on the breaking news that matters to you.</p>
<p>Best regards,
My App</p>
Completed 406 Not Acceptable in 161ms
ActionController::UnknownFormat - ActionController::UnknownFormat:
是什么原因造成的?
編輯1
請注意,這個錯誤是不一樣的其他錯誤。 在這種情況下,電子郵件已成功發送。 只是頁面/操作被重定向到它會產生錯誤。 這就是問題! 問題不在於您按下發送給用戶的確認電子郵件中的鏈接之后發生的事情。 成功發送確認電子郵件后,Rails應用程序會發生什么情況。 這就是為什么我將ConfirmationsController
粘貼在問題的頂部的原因,因為我懷疑它對於此問題很重要。
要重新發送確認說明( Resend Confirmation Instructions
),您在代碼中使用的幫助方法是什么?
可以通過以下兩種解決方案之一解決該問題:
解決方案1:
如果您使用了類似如下的參數,請刪除通過它的參數。
根據Github
( https://github.com/plataformatec/devise/issues/2834 )報告的問題:
在確認電子郵件視圖中,您可能正在將參數傳遞給url幫助器,如下所示:
user_confirmations_url(@some_variable)
該url不需要參數,因為您正在發送一個參數,所以將其設置為url格式,而不是替換url參數。
解決方案2:
引用此鏈接
希望有幫助:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.