I am getting this error while going into articles/new
my code :
new.html.erb :
<h1>Create an article</h1>
<%if @article.error.any? %>
<ul>
<% @article.errors.full_messages.each do |msg| %>
<li> <%= msg %> </li>
</ul>
<%= form_for @article do |f| %>
<p>
<%= f.label :title %>
<%= f.text_field:title %>
</p>
<p>
<%= f.label :description %>
<%= f.text_area :description %>
</p>
<p>
<%= f.submit %>
</p>
end
my articles_controller.erb file :
class ArticlesController < ApplicationController
def new
@article = Article.new
end
def create
@article = Article.new(article_params)
if @article.save
flash[:notice] = "Article was submitted succsefully"
redirect_to (@article)
else
render :new
end
end
private
def article_params
params.require(:article).permit(:title, :description)
end
end
ask me for any other files if it helps
Aucun commentaire:
Enregistrer un commentaire