未定义的方法`ARTICLE_NAME” ................. NoMethodError在ArticlesController#创建

问题描述:

class ArticlesController < ApplicationController 
    def index 
    @articles = Article.all 
    end 
    def show 
    @article = Article.find(params[ :id]) 
    end 
    def new 
    @article = Article.new 
    end 
    def create 
    @article = Article.new(article_params) 
     if @article.save 
    redirect_to @article 
    else 
    render 'new' 
    end 
    end 

    private 
    def article_params 
      params.require(:article).permit(:Article_name,:enter_text) 
    end 
end 
+0

可以使用你的代码{}在你的类文章编辑您的问题.. –

尝试用:

..... .permit(:name, :enter_text) 

你需要省略类名并只需指定数值名称。 请看下面的例子。

private 
    def article_params 
      params.require(:article).permit(:name, :enter_text) 
    end