没有路线匹配[GET]" / index" Ruby on Rails错误

时间:2016-05-23 19:39:41

标签: ruby-on-rails

我是Rails的新手,我的routes.rb

中有这个代码
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'

但是在localhost:3000 / index中它显示了这个错误

No route matches [GET] "/index"

可能是什么问题?

1 个答案:

答案 0 :(得分:2)

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

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

get 'index' => 'welcome#index' 

将生成您想要的路线。有关详细信息,请参阅文档http://guides.rubyonrails.org/routing.html