2012-04-24 53 views
0

所以你好!主要的未定義方法`root':對象

我想用紅寶石的軌道讓我的網站看起來不錯,並有良好的語言與紅寶石。我喜歡這款紅寶石,而且總是有。很好。

所以我的問題是,爲什麼我必須看到這個錯誤?

未定義的方法'根」主:對象

我得到這個,當我去我的網站,看看錯誤的PHUSION頁。這裏是長輸出:

Ruby on Rails應用程序無法啓動 這些是可能的原因: 應用程序代碼中可能存在語法錯誤。請檢查這些錯誤並修復它們。 可能未安裝必需的庫。請安裝此應用程序需要的所有庫。 應用程序可能未正確配置。請檢查所有配置文件是否寫入正確,修復任何不正確的配置,然後重新啓動此應用程序。 應用程序依賴的服務(如數據庫服務器或Ferret搜索引擎服務器)可能尚未啓動。請啓動該服務。 有關該錯誤的更多信息可能已寫入應用程序的日誌文件。請檢查它以分析問題。 錯誤信息:主 未定義的方法`根」:對象 Exception類: NoMethodError 應用根: /家庭/ $ USER/rails_apps /迷 回溯:

文件行位置

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 in 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/activ e_support/dependencies.rb 173 in 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/ruby​​gems/custom_require.rb 36 in 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 in initialize_server' 20 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb 204 in start_同步' 21 /usr/lib/ruby/gems/1.8/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb 180 in 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/乘客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 in 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

任何人都知道這是爲什麼發生?

以下規格是:

寶石列表--local軌

*當地的寶石*

軌(2.3.14)

紅寶石-v & &寶石-v 紅寶石1.8.7(2011-02-18 patchlevel 334)[x86_64-linux] 1.8.23

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

建議會很好,有幫助。坦克全部!附:請原諒我的英語技能 - 他們不好。

另外,我使用cPanel,但沒有使用cPanel帳戶來查看和處理這個應用程序。

回答

1

也許應用想讓您定義的config/routes.rb中的根路徑(詳情開放的config/routes.rb中)

+0

我有這樣的:#你可以有你的網站與map.root路由的根源 - 只記得刪除公共/ index.html的。 root:to =>「home#index」#查看所有路由如何使用「rake routes」#安裝默認路由作爲最低優先級。 #注意:這些默認路由使每個控制器中的所有操作都可以通過GET請求訪問。如果您使用命名路線和資源,您應該考慮刪除或註釋掉它們。 map.connect':controller /:action /:id'map.connect':controller /:action /:id。:format'end – 2012-04-25 00:07:35

+0

是的,如果你讀過它,寫上你應該設置'map.root' ;可能你刪除/重命名了public/index.html,這是由rails用來設置一個新項目的主頁,所以現在應用程序錯過了一個主頁;你應該指定主頁設置'map.root:controller =>「my_controller」'。說,我必須補充說你的config/routes.rb它比rails 2更類似於rails 2! – mdesantis 2012-04-25 00:16:02

+0

我應該怎樣做配置/路線。rb更像是導軌2? – 2012-04-25 00:32:11

0

希望這有助於在這裏......我基本上是一個全新安裝。我做了一個腳手架電話:

[email protected]:~/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 

紅寶石支架銷燬命令已經離開,其中搞砸了整個事情的routes.rb文件中的一個小行。沒有差異比較github,我從來沒有注意到。下面是在人的情況下原來的錯誤是盲目Google上搜尋它像我是...

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

warning: circular argument reference - now 


[email protected]:~/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>' 
相關問題