更新操作系统后 Rails 应用程序出现错误

发布于 2024-10-21 02:56:42 字数 1019 浏览 11 评论 0原文

我将系统更新为 opensuse 11.4 并通过 RVM 设置了 Ruby 1.9.2。我重新安装了所有宝石并更新了捆绑包,一切都没有问题。

问题是运行应用程序时出现的模糊错误:

ActionController::RoutingError (undefined method `sub' for nil:NilClass):
app/controllers/application_controller.rb:1:in `<top (required)>'
app/controllers/news_controller.rb:1:in `<top (required)>'

我什至不知道从哪里开始寻找问题。这两个文件的第 1 行都是类声明。即类 NewsController < ApplicationController 和类 ApplicationController <动作控制器::基础。这两个文件都没有对“sub”的方法调用,并且没有给出其他信息。

该应用程序在升级之前运行良好(也使用 Rails 3.0.5),所以我认为问题出在 Rails 中的某个地方,除了使用简单的脚手架运行新应用程序没有问题。 news#index 是路由文件中的根目录,但是将根目录更改为其他内容没有任何作用。

编辑:

resources :categories,:addresses,:calendars,:topics,:profile,:news,:account_setting
resources :boards do
member do
  get :move
  post :move_category
end
end


get "user/index"
get 'login/index'
get 'login/new'
post 'login/create'
post 'login/authenticate'
get 'login/forgot_password'
put 'login/reset_password'

root :to => "news#index"

I updated my system to opensuse 11.4 and set up Ruby 1.9.2 via RVM. I reinstalled all the gems and updated bundle all without issue.

The problem is the vague error I get when running the app:

ActionController::RoutingError (undefined method `sub' for nil:NilClass):
app/controllers/application_controller.rb:1:in `<top (required)>'
app/controllers/news_controller.rb:1:in `<top (required)>'

I don't even know where to start looking for the problem. Both files on line 1 is the class declaration. ie class NewsController < ApplicationController and class ApplicationController < ActionController::Base. Neither files have a method call to 'sub' and no other information is given.

The app worked perfectly before the upgrade (which was using Rails 3.0.5 also) so I think the issue is somewhere in Rails, except running a new application with a simple scaffold has no problems. news#index is root in the routes file, but changing root to something else does nothing.

EDIT:

resources :categories,:addresses,:calendars,:topics,:profile,:news,:account_setting
resources :boards do
member do
  get :move
  post :move_category
end
end


get "user/index"
get 'login/index'
get 'login/new'
post 'login/create'
post 'login/authenticate'
get 'login/forgot_password'
put 'login/reset_password'

root :to => "news#index"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤君无依 2024-10-28 02:56:42

不需要做这一切。我认为解决方案可能要简单得多。我刚刚得到同样的错误。原来我只是有一个命名错误的辅助模块:

module AssetHelper
  ...
end

应该是

module AssetsHelper
  ...
end

No need to do all that. I think the solution was probably a lot simpler. I just got the same error. Turns out I just had a misnamed helper module:

module AssetHelper
  ...
end

Should've been

module AssetsHelper
  ...
end
做个ˇ局外人 2024-10-28 02:56:42

我已经解决了,虽然我不知道是什么原因造成的。

我创建了一个新应用程序并复制了应用程序、路由、数据库、库和公共,问题就消失了。

I got it resolved, although I don't know what caused it.

I created a new app and copied over app, routes, db, lib, and public and the problem disappeared.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文