未定义的局部变量或方法“application_controller”对于主要:对象

发布于 2024-11-29 04:28:04 字数 3358 浏览 1 评论 0原文

我在设置 Rails 应用程序时遇到问题。我们使用rails 3(我们也使用memcached),并且我安装了所有东西(DB,ruby,rubygems,rails,...)并配置了DB。因此,如果我运行rails server,应用程序就会正常启动。

对于生产,我们将使用 Apache 和 Phusion Passenger,两者均已成功安装。 出现此错误:

**

[ pid=1557 thr=-608134948 file=utils.rb:176 time=2011-08-13 12:51:05.974 ]: *** Exception NameError in PhusionPassenger::Rack::ApplicationSpawner (undefined local variable or method `application_controller' for main:Object) (process 1557, thread #<Thread:0xb78131b8>):
    from /media/Disc/ABC/CODE/TESTINGAPP/app/controllers/application.rb:1
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:227:in `load_dependency'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:346:in `require_or_load'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:300:in `depend_on'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:216:in `require_dependency'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:138:in `eager_load!'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:137:in `each'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:137:in `eager_load!'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:135:in `each'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:135:in `eager_load!'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:108:in `eager_load!'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application/finisher.rb:41
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
    from /media/Disc/ABC/CODE/TESTINGAPP/config/environment.rb:5
    from config.ru:3:in `require'
    from config.ru:3
    from /usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
    from /usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
    from config.ru:1:in `new'
    from config.ru:1

当我重新启动 apache 时, 首先我认为这可能是 memcached 的问题,比如 apache 缺少一些模块,但我读到 apache/passenger 不需要配置。

我的问题是,为什么应用程序无法启动?我是否忘记安装或配置某些内容?我真的不知道可能出了什么问题,因为应用程序可以通过rails服务器正常启动。

提前告知;)

I have a problem with setting up rails application. We use rails 3 (we also use memcached), and have I installed everthing (DB, ruby, rubygems, rails, ...) and configure the DB. So if I run rails server the apllication starts ok.

For production we will use Apache and Phusion Passenger, both have been installed sucessfuly. When I restart apache I get this error:

*

[ pid=1557 thr=-608134948 file=utils.rb:176 time=2011-08-13 12:51:05.974 ]: *** Exception NameError in PhusionPassenger::Rack::ApplicationSpawner (undefined local variable or method `application_controller' for main:Object) (process 1557, thread #<Thread:0xb78131b8>):
    from /media/Disc/ABC/CODE/TESTINGAPP/app/controllers/application.rb:1
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:227:in `load_dependency'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:346:in `require_or_load'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:300:in `depend_on'
    from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:216:in `require_dependency'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:138:in `eager_load!'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:137:in `each'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:137:in `eager_load!'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:135:in `each'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/engine.rb:135:in `eager_load!'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:108:in `eager_load!'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application/finisher.rb:41
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
    from /media/Disc/ABC/CODE/TESTINGAPP/config/environment.rb:5
    from config.ru:3:in `require'
    from config.ru:3
    from /usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
    from /usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
    from config.ru:1:in `new'
    from config.ru:1

*
First I thought that it might be sometnig with memcached, like some missing module for apache, but I read that there is no configuration needed for apache/passenger.

My question is, why application doesn't start? Have I forgot to install or configure someting? I really don't know what might be wronge since the application starts ok with rails server.

Tnx in advance ;)

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

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

发布评论

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

评论(1

请爱~陌生人 2024-12-06 04:28:04

看一下这个文件:

/media/Disc/ABC/CODE/TESTINGAPP/app/controllers/application.rb

从 Rails 2.3 开始,这个文件应该被称为 application_controller.rb 而不是 application.rb。重命名该文件,它应该可以工作:

/media/Disc/ABC/CODE/TESTINGAPP/app/controllers/application_controller.rb

Look at this file:

/media/Disc/ABC/CODE/TESTINGAPP/app/controllers/application.rb

Since Rails 2.3 this file should be called application_controller.rb and not application.rb. Rename the file and it should work:

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