我正在尝试完成本教程:http://guides.rubyonrails.org/getting_started.html#say-hello-rails,但出现错误:

<%= form_for :article, url: articles_path do |f| %>

我有下一个错误:
undefined local variable or method `articles_path' for #<#<Class:0x4646c28>:0x4661d30>
Extracted source (around line #1):
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`
ArcticlesController:
class ArticlesController < ApplicationController
  def new
  end

  def create
  end
end

请帮助!

最佳答案

我猜您忘了在resources :articles文件中添加config/routes.rb。如指南中所述:

Blog::Application.routes.draw do

  resources :articles

  root 'welcome#index'
end

关于ruby-on-rails - 未定义的局部变量或方法 "articles_path",我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23860810/

10-12 19:52