0

我的问题是,为什么我必须看到这个错误?

main:Object 的未定义方法“root”

当我访问我的网站并查看 Phusion 错误页面时,我得到了这个。这是长输出:

无法启动 Ruby on Rails 应用程序 可能的原因如下: 应用程序代码中可能存在语法错误。请检查此类错误并修复它们。可能未安装所需的库。请安装此应用程序所需的所有库。应用程序可能未正确配置。请检查所有配置文件是否正确写入,修复任何不正确的配置,然后重新启动该应用程序。应用程序依赖的服务(例如数据库服务器或 Ferret 搜索引擎服务器)可能尚未启动。请启动该服务。有关错误的更多信息可能已写入应用程序的日志文件。请检查它以便分析问题。错误消息:main:Object 异常类的未定义方法“root”:

文件行位置 0 /home/$user/rails_apps/$app/config/routes.rb 34

1 /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/routing/route_set.rb 227 在 draw' 2 /home/$user/rails_apps/$app/config/routes.rb 1 3 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb 173 in load_without_new_constant_marking' 4 /usr/lib/ruby/gems/1.8/gems/activesupport-2.3 .14/lib/active_support/dependencies.rb 173 在 load' 5 /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/routing/route_set.rb 287 in load_routes!6 /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/routing/route_set.rb 287 in each' 7 /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/routing/route_set.rb 287 in load_routes!8 /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/routing/route_set.rb 267 in reload!' 9 /usr/lib/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb 537 in initialize_routing' 10 /usr/lib/ruby/gems/1.8/gems/rails-2.3 .14/lib/initializer.rb 188 在 process' 11 /usr/lib/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb 113 in 发送'12 /usr/lib/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb 113 在 run' 13 /home/$user/rails_apps/$app/config/environment.rb 9 14 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb 36 in gem_original_require' 15 /usr/lib/ruby/site_ruby /1.8/rubygems/custom_require.rb 36 英寸 require' 16 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/classic_rails/application_spawner.rb 222 in preload_application' 17 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/classic_rails/application_spawner.rb 181 in initialize_server' 18 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/utils.rb 572 in report_app_init_status' 19 /usr/lib/ruby/gems/1.8/gems/passenger -3.0.12/lib/phusion_passenger/classic_rails/application_spawner.rb 174 在initialize_server' 20 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb 204 in start_synchronously' 21 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb 180 在 start' 22 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/classic_rails/application_spawner.rb 149 in start' 23 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 219 在 spawn_rails_application' 24 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb 132 in lookup_or_add' 25 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/ lib/phusion_passenger/spawn_manager.rb 214 在 spawn_rails_application' 26 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb 82 in 同步'27 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb 79 synchronize' 28 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 213 in spawn_rails_application' 29 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 132 in spawn_application' 30 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 275 in handle_spawn_application' 31 /usr/lib/ruby/gems/1.8/gems/passenger-3.0 .12/lib/phusion_passenger/abstract_server.rb 357 在 __send__' 32 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb 357 in server_main_loop' 33 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb 206 在 `start_synchronously' 34 /usr/ lib/ruby/gems/1.8/gems/passenger-3.0.12/helper-scripts/passenger-spawn-server 99

这里的规格是:

宝石列表--本地导轨

*** 当地宝石 ***

导轨 (2.3.14)

ruby -v && gem -v ruby​​ 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux] 1.8.23

在我的 config/environment.rb 我指定 rails 2.3.14

另外,我正在使用 cPanel 但不使用 cPanel 帐户来查看和处理此应用程序。

4

2 回答 2

1

可能应用程序希望您在 config/routes.rb 中定义根路由(打开 config/routes.rb 了解详细信息)

于 2012-04-24T23:59:48.320 回答
0

希望这在这里有所帮助……我基本上是全新安装的。我拨打了脚手架电话:

mirv@rorblog:~/workspace/workspace (master) $ rails g scaffold User userID:integer index  name:string email:string password:string lastLogin:datetime

这显然是错误的……但是如何撤消呢?因为我后来错误地执行了“rake db:migrate”,认为我们可以用一个简单的命令来删除它。错了,但幸运的是,在比较了我的 github 之后,我注意到我的 routes.rb 文件的开头有所不同。

resources :users

ruby scaffold destroy 命令在 routes.rb 文件中留下了一小行,这把整个事情搞砸了。如果没有在 github 上进行比较,我永远不会注意到。以下是最初的错误,以防人们像我一样盲目地搜索它......

`<top (required)>': undefined method `resources' for main:Object (NoMethodError)

warning: circular argument reference - now


mirv@rorblog:~/workspace/workspace (master) $ rails s -p $PORT -b $IP
    /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.1.0/lib/active_support/values/time_zone.rb:285: warning: circular argument reference - now
    => Booting WEBrick
    => Rails 4.1.0 application starting in development on http://0.0.0.0:8080=> Run `rails server -h` for more startup options
    => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
    => Ctrl-C to shutdown server
    Exiting
    /home/ubuntu/workspace/config/routes.rb:2:in `<top (required)>': undefined method `resources' for main:Object (NoMethodError)
            from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `load'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `block in load'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in `load_dependency'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `load'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:40:in `each'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:40:in `load_paths'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:16:in `reload!'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:26:in `block in updater'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.1.0/lib/active_support/file_update_checker.rb:75:in `call'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.1.0/lib/active_support/file_update_checker.rb:75:in `execute'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:27:in `updater'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/application/finisher.rb:71:in `block in <module:Finisher>'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/initializable.rb:30:in `instance_exec'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/initializable.rb:30:in `run'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/initializable.rb:55:in `block in run_initializers'
            from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
            from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
            from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
            from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
            from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each'
            from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `call'
            from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
            from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
            from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/initializable.rb:54:in `run_initializers'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/application.rb:288:in `initialize!'
            from /home/ubuntu/workspace/config/environment.rb:5:in `<top (required)>'
            from /home/ubuntu/workspace/config.ru:3:in `require'
            from /home/ubuntu/workspace/config.ru:3:in `block in <main>'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/builder.rb:55:in `instance_eval'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/builder.rb:55:in `initialize'
            from /home/ubuntu/workspace/config.ru:in `new'
            from /home/ubuntu/workspace/config.ru:in `<main>'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/builder.rb:49:in `eval'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/builder.rb:49:in `new_from_string'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/builder.rb:40:in `parse_file'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/server.rb:277:in `build_app_and_options_from_config'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/server.rb:199:in `app'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands/server.rb:50:in `app'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/server.rb:314:in `wrapped_app'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands/server.rb:130:in `log_to_stdout'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands/server.rb:67:in `start'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:81:in `block in server'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `tap'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `server'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.1.0/lib/rails/commands.rb:17:in `<top (required)>'
            from /home/ubuntu/workspace/bin/rails:8:in `require'
            from /home/ubuntu/workspace/bin/rails:8:in `<top (required)>'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/client/rails.rb:28:in `load'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/client/rails.rb:28:in `call'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/client/command.rb:7:in `call'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/client.rb:26:in `run'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.3.6/bin/spring:48:in `<top (required)>'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/binstub.rb:11:in `load'
            from /usr/local/rvm/gems/ruby-2.2.1/gems/spring-1.3.6/lib/spring/binstub.rb:11:in `<top (required)>'
            from /home/ubuntu/workspace/bin/spring:13:in `require'
            from /home/ubuntu/workspace/bin/spring:13:in `<top (required)>'
            from bin/rails:3:in `load'
            from bin/rails:3:in `<main>'
于 2015-06-17T21:37:37.473 回答