gpt4 book ai didi

ruby - 为什么我得到 "uninitialized constant ApplicationController::SessionsHelper (NameError)"?

转载 作者:太空宇宙 更新时间:2023-11-03 17:54:02 25 4
gpt4 key购买 nike

我正在学习 Michael Hart 的教程,但出现错误:

rails_projects/sample_app/app/controllers/application_controller.rb:3:in `<class:ApplicationController>': uninitialized constant ApplicationController::SessionsHelper (NameError)

这是我的 application_controller.rb 文件:

class ApplicationController < ActionController::Base
protect_from_forgery
include SessionsHelper

# Force signout to prevent CSRF attacks
def handle_unverified_request
sign_out
super
end
end

最佳答案

您应该在 app/helpers 中有一个名为“sessions_helper.rb”的文件。在里面你至少应该有这样的代码:

module SessionsHelper
end

希望对您有所帮助。

关于ruby - 为什么我得到 "uninitialized constant ApplicationController::SessionsHelper (NameError)"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17984330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com