繁体   English   中英

ActionController :: UnknownFormat设计确认

[英]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:

如果您使用了类似如下的参数,请删除通过它的参数。

根据Githubhttps://github.com/plataformatec/devise/issues/2834 )报告的问题:

在确认电子邮件视图中,您可能正在将参数传递给url帮助器,如下所示:

user_confirmations_url(@some_variable)

该url不需要参数,因为您正在发送一个参数,所以将其设置为url格式,而不是替换url参数。

解决方案2:

引用此链接

希望有帮助:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM