在[GET]" / articles / new"'中路由错误

时间:2014-06-21 22:15:00

标签: ruby-on-rails ruby rails-routing

我正在阅读“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

1 个答案:

答案 0 :(得分:7)

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

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

您可以在Ruby on Rails Guides中了解有关路由的详情。