我正在读“Rails入门”,我被困在第5.1章我试过:

rails g controller articles

我试图打开articles/new,收到以下错误消息:
No route matches [GET] "/articles/new"
Rails.root: C:/Sites/blog

然后运行rake routes,命令提示:
You don't have any routes defined!  Please add some routes in config/routes.rb'

这是我的routes.rb
  Blog::Application.routes.draw do
  get "welcome/index"

  root 'welcome#index'
end

最佳答案

您需要将resources :articles添加到routes.rb

Blog::Application.routes.draw do
  root 'welcome#index'
  resources :articles
end

您可以在Ruby on Rails Guides中了解有关路由的更多信息。

关于ruby-on-rails - [GET]“/articles/new”中的路由错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24346331/

10-13 01:26