2015-10-05 54 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

相關問題