2012-11-11 37 views
0

重新開始使用RoR!我無法讓我的config/routes.rb文件執行。我使用RubyMine獲得「未初始化的常量ApplicationsController」。使routes.rb root在Rails中工作

下面是我在routes.rb中改變試圖尋找下來後:

resources :applications 
root :to => 'applications#index' 

application_controller.rb has: 
    class ApplicationController < ActionController::Base 
    protect_from_forgery 
end 

我跑我耙路線:

applications GET /applications(.:format)   applications#index 
       POST /applications(.:format)   applications#create 
new_application GET /applications/new(.:format)  applications#new 
edit_application GET /applications/:id/edit(.:format) applications#edit 
    application GET /applications/:id(.:format)  applications#show 
       PUT /applications/:id(.:format)  applications#update 
       DELETE /applications/:id(.:format)  applications#destroy 
      root  /        applications#index 

rake rails:update和批准除了所有更改改變路線.rb 繼承人什麼它踢出盧西姬方:

Started GET "/" for 127.0.0.1 at 2012-11-11 02:50:27 -0800 
Connecting to database specified by database.yml 

ActionController::RoutingError (uninitialized constant ApplicationsController): 

感謝您的幫助!

回答

0

檢查,如果你在你的文件夾app/controller有一個叫做applications_controller文件,或者它的名字是application_controller,所以其重命名爲applications_controller,如果你沒有這個文件,然後創建您ApplicationsController

rails generate controller applications

+0

最終必須生成一個名爲applications_controller.rb的全新控制器。謝謝 – Matt

1

您應該重命名application_controller.rbapplications_controller.rb

+0

嗯多個問題與文件的命名?或生成問題? – Matt

+0

@Matt在rails中,這被稱爲*約定而不是配置*。默認情況下,所有控制器都必須複用。型號:用戶控制器:UsersController –