2016-05-23 228 views
0

我是新来的导轨和我在routes.rb中得到这个代码没有路由匹配[GET]“/指数” Ruby on Rails的错误

Rails.application.routes.draw do 
    get 'welcome/index' => 'welcome#index' 
    # The priority is based upon order of creation: first created -> highest priority. 
    # See how all your routes lay out with "rake routes". 

    # You can have the root of your site routed with "root" 
    root 'welcome#index' 

但在本地主机:3000 /索引它为我此错误

No route matches [GET] "/index" 

可能是什么问题?

回答

2
get 'welcome/index' => 'welcome#index' 

此代码将生成localhost:3000/welcome/index的路由。

get 'index' => 'welcome#index' 

会产生你想要的路线。请参阅文档http://guides.rubyonrails.org/routing.html

+1

感谢它的工作!我会接受你的答案在9分钟:) –

+0

很高兴我可以帮助!希望您到目前为止享受rails和ruby,这是一个非常棒的社区! –

相关问题