我是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"
可能是什么问题?
答案 0 :(得分:2)
get 'welcome/index' => 'welcome#index'
此代码将为localhost生成路由:3000 / welcome / index。
get 'index' => 'welcome#index'
将生成您想要的路线。有关详细信息,请参阅文档http://guides.rubyonrails.org/routing.html