저는 Ruby를 처음 사용합니다. 간단한 게시 응용 프로그램을 만드는 방법에 대한 지침을 따르려고합니다.Ruby on Rails가 작동하지 않는 동작을 생성합니다.
내 생성 동작이 작동하지 않습니다. 이 시도하고 터미널에서 뭔가를 할 것으로 보이지만 내 게시물 개체에 추가하지 않습니다. 내가 제출하려고 할 때
<h1>Add a New Post</h1>
<%= form_for @post do |f| %>
<p>
<%= f.label :title %>
<%= f.text_field :title %>
</p>
<p>
<%= f.label :content %>
<%= f.text_area :content %>
</p>
<p>
<%= f.submit "Add a New Post" %>
</p>
<% end %>
이 터미널에서 오는 것입니다 :
여기class PostsController < ApplicationController
def index
@posts = Post.all
end
def show
@post = Post.find(params[:id])
end
def new
@post = Post.new
end
def create
@post = Post.new(:title => params[:title], :content => params[:content])
@post.save
end
def edit
end
def update
end
def destroy
end
end
나의 새로운이다 : 여기
내 게시물 컨트롤러Started POST "/posts" for ::1 at 2016-08-31 17:54:39 -0700
ActiveRecord::SchemaMigration Load (16.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by PostsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"tGpevHtpEoP5jHYqCn1G7tUKX9YWnx+PWkqlPzKadTCiIEX1UGs96mSCrDf UIShKjp+ObwNA6G1nh3KE5gAIgw==", "post"=>{"title"=>"Jack's Post", "content"=>"Please use this post"}, "commit"=>"Add a New Post"}
(0.1ms) begin transaction
SQL (16.0ms) INSERT INTO "posts" ("created_at", "updated_at") VALUES (?, ?) [["created_at", 2016-09-01 00:54:40 UTC], ["updated_at", 2016-09-01 00:54:40 UTC]]
(14.7ms) commit transaction
No template found for PostsController#create, rendering head :no_content
Completed 204 No Content in 114ms (ActiveRecord: 31.3ms)
나는 이것에 관한 백만개의 스택 오버플로에 대한 글을 읽은 것 같아 아무도 대답을 얻지 못하는 것 같다. 어떤 도움을 주시면 감사하겠습니다!
강한 매개 변수는 영업 이익이 따르는 튜토리얼에 포함되지 않을 수 있습니다. 나는 그들에 대해 들어 보지 못했다. (나는 여전히 Rails 3.x에있다.) 빨리가! – Mick
그래서 두 가지 솔루션을 모두 제공했습니다. :) @MickSharpe – codyeatworld
정말 고마워요! 그것은 효과가있다! 나는 이것이 내가하는 일을하는 이유를 이해할 수 없다는 것을 완전히 확신하지 못한다. 그러나 나는 계속해서 그것을 알아낼 것이다. –