更新操作系统后 Rails 应用程序出现错误
我将系统更新为 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不需要做这一切。我认为解决方案可能要简单得多。我刚刚得到同样的错误。原来我只是有一个命名错误的辅助模块:
应该是
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:
Should've been
我已经解决了,虽然我不知道是什么原因造成的。
我创建了一个新应用程序并复制了应用程序、路由、数据库、库和公共,问题就消失了。
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.