未定义的局部变量或方法"articles_path"

avm*_*tte 5 ruby routes ruby-on-rails

我正在尝试完成本教程:http://guides.rubyonrails.org/getting_started.html#say-hello-rails但我收到的错误是:

<%= form_for :article, url: articles_path do |f| %>
Run Code Online (Sandbox Code Playgroud)

我有下一个错误:

undefined local variable or method `articles_path' for #<#<Class:0x4646c28>:0x4661d30>
Extracted source (around line #1):       
Run Code Online (Sandbox Code Playgroud)

rake routes:

Prefix Verb URI Pattern                      Controller#Action
welcome_index GET /welcome/index(.:format)   welcome#index
 articles_new GET /articles/new(.:format)    articles#new
         root GET /                          welcome#index`
Run Code Online (Sandbox Code Playgroud)

ArcticlesController:

class ArticlesController < ApplicationController
  def new
  end

  def create
  end
end
Run Code Online (Sandbox Code Playgroud)

请帮忙!

zis*_*she 13

我想你忘记添加resources :articles你的config/routes.rb文件了.正如在指南中所做的那样:

Blog::Application.routes.draw do

  resources :articles

  root 'welcome#index'
end
Run Code Online (Sandbox Code Playgroud)