2015-10-05 53 views
1

我有在FLE new.html.erb桶应用了一个问题:未定义的方法`articles_path” <#<类别:0xb4107fc0>:0xb498bf48>

<%= form_for @article do |f| %> 
    <%= f.text_field :title %> 
    <%= f.text_area :text %> 
    <%= f.submit %> 
<% end %> 

我的routes.rb具有:

resources :atricles 

我static_pages_controller.rb具有代码:

def manager 
    @contact_messages = ContactForm.all 
    @item = Item.new 
    @items = Item.all 
    @article = Article.new 
    end 

我articles_controller.rb是:

class ArticlesController < ApplicationController 
    def new 
     @article = Article.new 
    end 
    def create 
     @article = Article.new article_params 
     @article.save 
    end 

    private 

    def article_params 
     params.require(:article).permit(:title, :text) 
    end 
end 

我迁移文件是:

class CreateArticles < ActiveRecord::Migration 
    def change 
    create_table :articles do |t| 
     t.string :title 
     t.text :text 

     t.timestamps null: false 
    end 
    end 
end 

我的应用程序/模型/ article.rb是:

class Article < ActiveRecord::Base 
end 

感谢

回答

2

错字:resources :atricles应该resources :articles

6

在你的routes.rb,p改正拼写。它应该是articles不是atricles

+0

谢谢,这有帮助! :) – verrom

相关问题