这是我的控制人
class LoginsController < ApplicationController
def new
end
def create
student = Student.find_by(email: params[:logins][:email].downcase)
if student && student.authenticate(params[:logins][:password])
session[:student_id] = student.id
flash[:notice] = "You have successfully logged in"
redirect_to student
else
flash.now[:notice] = "Something was wrong with your login information"
render 'new'
end
end
def destroy
session[:student_id] = nil
flash[:notice] = "You have successfully logged out"
redirect_to root_path
end
end
这是我的路线
get 'login', to: 'logins#new'
post 'login', to: 'logins#create'
delete 'logout', to: 'login#destroy'
当我单击注销按钮时,它给出路由错误未初始化的常量LoginController
这是项目link的github链接
答案 0 :(得分:1)
您的路线中有错别字:
将delete'logout'更改为:'login#destroy',将delete'logout'更改为:'logins#destroy'