決定嘗試學習RoR。卡在Rails Guides的最開始。你好,Rails!沒有路線匹配[GET]「/」
所做的一切完全像在教程中(除del public/index.html
而不是rm public/index.html
,因爲我有一個Windows)檢查本地主機和獲取:
沒有路由匹配[GET] 「/」
決定嘗試學習RoR。卡在Rails Guides的最開始。你好,Rails!沒有路線匹配[GET]「/」
所做的一切完全像在教程中(除del public/index.html
而不是rm public/index.html
,因爲我有一個Windows)檢查本地主機和獲取:
沒有路由匹配[GET] 「/」
我認爲你刪除index.html後不設置根路徑?
也許把你的路線
root :to => 'post#index'
你應該增加:
root :to => 'home#index'
看到教程
第4.2 root
路由是Rails應用程序的缺省路由。 您可以將此指向任何您希望顯示爲「主頁面」的控制器和操作。
root :to => "controller#action"
明白了。謝謝! – sharls
您的站點需要某種根目錄。如果某些索引文件不存在public /(index.html | htm,default.html | htm等),那麼您需要告訴您的rails應用程序要去哪裏。
您可以通過編輯您的routes.rb(在你的config /文件夾中找到),並加入行
root :to => 'somecontroller#index"
somecontroller
代表控制器使用做到這一點,index
代表,它應該處理的方法。典型的指標是首選,這會使index.html.erb
您可以通過在控制檯輸入
rake routes
瞭解更多航線。
查看刪除'index.html'後立即查看該步驟。 –