简体   繁体   中英

ActionController::UnknownFormat Devise Confirmation

Whenever I have a user that has not confirmed their account, if I click on "Resend Confirmation Instructions" after putting in the correct email address, an email gets successfully sent (in development anyway) and then I get this error message:

ActionController::UnknownFormat at /users/confirmation.user
ActionController::UnknownFormat

At this URL:

http://localhost:3000/users/confirmation.user

Here is my ConfirmationsController

class ConfirmationsController < Devise::ConfirmationsController
  private
  def after_confirmation_path_for(resource_name, resource)
    new_session_path(resource_name)
  end
end

Here is the log for the entire event:

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:

What could be causing this?

Edit 1

Please note that this error is NOT the same as other errors. In this case, the email IS successfully sent. It is just the page/action that it is redirected to that generates the error. THAT is the issue! The issue IS NOT with what happens AFTER you press the link in the confirmations email that is sent to the user. It is what happens to the Rails app AFTER the confirmation email is successfully sent. That is why I pasted the ConfirmationsController at the top of the question, because I suspect it is central to this issue.

For re-sending the confirmation instructions ( Resend Confirmation Instructions ), what is the helper method you have used in your code?

It can be resolved in either of 2 solutions mentioned below:

Solution 1:

If you have used a similar one like below, please remove the parameter you have passed through it.

As per the issue reported on Github ( https://github.com/plataformatec/devise/issues/2834 ):

In your confirmation email view you're probably passing a parameter to your url helper, something like this:

user_confirmations_url(@some_variable)

That url does not require an argument and because you are sending one, it is being set as the url format instead of replacing a url parameter.

Solution 2:

Refer this link

Hope that helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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