記事/新しく出ているうちにこのエラーが発生します。記事を見ようとしているときにエラーが発生しました
私のコード:
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
私articles_controller.erbファイル:それならば
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
は、他のファイルのために私に尋ねます助けてください
私は彼が近いですが、本当の問題は、単語が '' new.htmlの一番下にend'ということです –
あなたが言っているあなたは、もう少し明確に例とすることができるか理解していません。 '<% end %>' – jrabramson
はい@jrabramson、あなたは正しいです。私は答えを更新しました。 –