Anagha R
Anagha R

Reputation: 1

undefined method `article_name' .................NoMethodError in ArticlesController#create

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

Upvotes: 0

Views: 44

Answers (2)

Ramsy de Vos
Ramsy de Vos

Reputation: 1072

You need to omit the class name and just specify the value name. See the example below.

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

Upvotes: 0

Alexander Lazarov
Alexander Lazarov

Reputation: 578

Try with:

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

Upvotes: 1

Related Questions