私は少し迷っています。Rails 4 エラーが発生しています: ActiveModel::ForbiddenAttributesError. これは、アイテムの通過を許可する必要があることを意味することを理解していますが、それは行っていますが、何かが足りないに違いありません。
コメント コントローラ:
class CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create!(params[:comment])
redirect_to @post
end
private
# Never trust parameters from the scary internet, only allow the white list through.
def comment_params
params.require(:comment).permit(:post_id, :comment, :body)
end
end
コメント移行の作成
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.references :post
t.text :body
t.timestamps
end
end
def self.down
drop_table :comments
end
end
ここで何が欠けていますか?他のコードを見る必要がある場合はお知らせください。
ありがとう!