0
일부 데이터를 db 및 ok로 제출하려고 시도하지만 해당 데이터를 검색하려고 할 때 ID없이 기사를 찾을 수 없습니다. .ils 4.0.1. 나는 루비 2.0.0와 라ArticlesController # ActiveRecord :: RecordNotFound ID없이 기사를 찾을 수 없습니다
def show
@article=Article.find(params[:id])
끝
the ** contain error.
class ArticlesController < ApplicationController
def new
end
def create
@article = Article.new(article_params)
redirect_to @article
@article.save
end
def show
@article=Article.find(params[:id])
end
private
def article_params
params.require(:article).permit(:title, :full_name, :email, :phone_number, :message)
end
end
기사/show.html.erb를 사용하고
<p>
<strong>Title:</strong>
<%= @article.title %>
</p>
<p>
<strong>Full Name:</strong>
<%= @article.full_name %>
</p>
<p>
<strong>Email:</strong>
<%= @article.email %>
</p>
<p>
<strong>Phone Number:</strong>
<%= @article.phone_number %>
</p>
<p>
<strong>Message:</strong>
<%= @article.message %>
</p>
기사/new.html.erb
<h1>New Articles</h1>
<%= form_for :article, url: articles_path do |f| %>
<p>
<%= f.label :title %>
<%= f.text_field :title %>
<p>
<%= f.label :full_name %>
<%= f.text_field :full_name %>
</p>
<%= f.label :email %>
<%= f.text_field :email %>
<p>
<%= f.label :phone_number %>
<%= f.text_field :phone_number %>
</p>
<%= f.label :message %>
<%= f.text_field :message %>
<p>
<%= f.submit :send_message %>
</p>
<% end %>
다시 리디렉션 오류. –
ArticleController에서 NoMethodError는 #