我在制作我的应用程序,当我尝试登录时出现此错误。代码是这样的:
查看:
= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
.col-xs-12
= devise_error_messages!
.col-xs-12.field
= f.label :email
= f.email_field :email, autofocus: true, class:"form-control"
.col-xs-12.field
= f.label :password
= f.password_field :password, autocomplete: "off", class:"form-control"
- if devise_mapping.rememberable?
.col-xs-12.field.remember-me
.col-xs-12.col-sm-6.remember
= f.check_box :remember_me
= f.label :remember_me
.col-xs-12.col-sm-6.forgot-password
= link_to "Forgot your password?", new_password_path(resource_name)
.col-xs-12.actions.text-center
= f.submit "Log in", class: "btn btn-default principal-btn"
.col-xs-12.links.text-center
= link_to "Sign up", new_registration_path(resource_name)
会话控制器:
class Users::SessionsController < Devise::SessionsController
# before_action :configure_sign_in_params, only: [:create]
# GET /resource/sign_in
# def new
# super
# end
# POST /resource/sign_in
# def create
# super
# end
end
在应用程序控制器中:
protect_from_forgery with: :exception, prepend: true
版本:
devise (4.2.0)
rails (5.0.0.1)
unicorn (5.1.0)
unicorn-rails (2.2.1)
ruby (2.3.1)
我的服务器是一个aws实例,应用程序是用unicorn启动的。
我试过了:
# Users::SessionsController
skip_before_action :verify_authenticity_token, only: [:create]
和
# ApplicationController
protect_from_forgery with: :null_sessions
但这是不确定的,并且没有创建会话。所以,我不知道解决这个问题的另一种方法。