简体   繁体   English

是否找不到application.rb定义的方法?

[英]application.rb defined methods not being found?

I'm working on a project where I've inherited some legacy code from an old version of Rails (1 or 2, I think). 我正在一个项目中,该项目已从旧版本的Rails(我认为是1或2)继承了一些旧代码。 After tinkering with it, I tried starting it up, but I'm running into trouble in one of my controllers. 修改之后,我尝试启动它,但是我的一个控制器遇到了麻烦。 Specifically, the line @user = current_user || User.new 具体来说, @user = current_user || User.new @user = current_user || User.new is stating that current_user can't be found. @user = current_user || User.new指出找不到current_user。 After doing some digging, I see that def current_user is hanging out in my application.rb file. 进行一些挖掘之后,我发现def current_user在我的application.rb文件中闲逛。 Why isn't the app loading this method? 为什么应用程序不加载此方法?

Am I misunderstanding how application.rb is supposed to work? 我是否误解了application.rb应该如何工作?

(If it matters, this method seems to be protected, but I don't know how that would prevent the app from seeing this definition.) (如果很重要,则此方法似乎受到保护,但是我不知道该怎么阻止应用程序看到此定义。)

请参阅原始问题的注释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM