如果我单击注销按钮,我会收到此错误:检查结果必须仅为 ASCII 或使用与默认外部相同的编码
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
before_action :authenticate_user!
before_action :configure_permitted_parameters, if: :devise_controller?
protect_from_forgery with: :exception
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:username, :email) }
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :password_confirmation) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) }
end
end
关联:
<%= link_to "Logout", logout_path, title: "Logout", method: :delete %>
路线:
devise_scope :user do
get 'register', to: 'devise/registrations#new', as: 'register'
get 'login', to: 'devise/sessions#new', as: 'login'
delete 'logout', to: 'devise/sessions#destroy', as: 'logout'
end
我不知道问题出在哪里。
如果我删除这 3 行,那么它可以工作,但我无法注册新用户:
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:username, :email) }
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :password_confirmation) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) }
谢谢!