unde的方法`root'for main:Object

时间:2012-04-24 23:45:06

标签: ruby-on-rails ruby linux cpanel phusion

所以大家好!

我想使用带有红宝石的rails来让我的网站看起来很漂亮并且使用ruby语言很好。我喜欢红宝石,而且总是如此。很好。

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

主要的未定义方法`root':对象

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

无法启动Ruby on Rails应用程序 这些是可能的原因: 应用程序代码中可能存在语法错误。请检查此类错误并进行修复。 可能未安装所需的库。请安装此应用程序所需的所有库。 可能未正确配置应用程序。请检查是否所有配置文件都已正确写入,修复任何错误配置,然后重新启动此应用程序。 应用程序所依赖的服务(例如数据库服务器或Ferret搜索引擎服务器)可能尚未启动。请开始这项服务。 有关错误的更多信息可能已写入应用程序的日志文件。请检查它以分析问题。 错误信息: unde的方法`root'for main:Object 例外类: NoMethodError 应用程序根: /家庭/ $ USER / rails_apps /迷 回溯:

文件行位置

0 /home/$user/rails_apps/$app/config/routes.rb 34
1 {us} / load / unt / __ {/ 1}} load_routes!中的/u​​sr/lib/ruby/gems/1.8/gems/activesupport-2.3.14/lib/active_support/dependencies.rb 173 6 /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/routing/route_set.rb 287 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_routes!' 8 /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/routing/route_set.rb 267 load' 5 /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/routing/route_set.rb 287 in initialize_routing' 10 /usr/lib/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb 188 each' 7 /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.14/lib/action_controller/routing/route_set.rb 287 in发送' 12 {us(1)} {_ 1}} 在reload!' 9 /usr/lib/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb 537 in preload_application'中15 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb 36 17 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/classic_rails/application_spawner.rb 181 process' 11 /usr/lib/ruby/gems/1.8/gems/rails-2.3.14/lib/initializer.rb 113 in report_app_init_status' 19 {us} {发送同步'{{ 21 /us {/ 1/2} {/ 1}} lookup_or_add'中的/usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 219 {/ 1}} synchronize中的/usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 214 27 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb 79 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
spawn_rails_application' 29 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 132 require' 16 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/classic_rails/application_spawner.rb 222 in handle_spawn_application' 31 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb 357 initialize_server' 18 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/utils.rb 572 in server_main_loop' 33在`start_synchronously'中的/usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb 206 34 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/helper-scripts/passenger-spawn-server 99

任何人都知道为什么会这样吗?

这里的规格是:

gem list --local rails

*本地宝石*

rails(2.3.14)

ruby​​ -v&&宝石-v ruby 1.8.7(2011-02-18 patchlevel 334)[x86_64-linux] 23年1月8日

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

建议会很好,也很有帮助。坦克全部!附:请原谅我的英语技能 - 他们不好。

此外,我使用的是cPanel,但没有使用cPanel帐户来查看和处理此应用程序。

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分: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>'