简体   繁体   中英

Devise, ActionController::UnknownFormat

I am using devise for authentication, and my application send email with confirmation, but when I click 'confirm my account' I have this error:

ActionController::UnknownFormat

Where is my problem?

my application_controller.rb

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  before_action :configure_permitted_parameters, if: :devise_controller?

  def authenticate_admin_user!
    authenticate_user!
    redirect_to root_path unless current_user.admin?
  end

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) << :first_name << :last_name
  end
end

my confirmation_instructions.html

<p>Welcome <%= @email %>!</p>

<p>You can confirm your account email through the link below:</p>

<p><%= link_to 'Confirm my account', user_confirmation_url(@resource, confirmation_token: @token) %></p>

Just add this respond_to :html, :json line in your application controller

class ApplicationController < ActionController::Base
  respond_to :html, :json
  ...

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