0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

エラー発生→解決

Posted at

備忘録として、こんな事で悩んでたなーと将来見返すときの為に記述します。

エラーコード
ActiveModel::UnknownAttributeError in PrototypesController#create
unknown attribute 'prototype_id' for Prototype.

今までできていた新規投稿が出来なくなった。
createアクションの記述が間違い?

訂正前
def prototype_params
params.require(:prototype).permit(:title, :catch_copy, :image, :concept).merge(user_id: current_user.id, prototype_id: params[:prototype_id])
end

訂正後
def prototype_params
params.require(:prototype).permit(:title, :catch_copy, :image, :concept).merge(user_id: current_user.id)
end

そもそもprototypeにidは必要ないので削除したら保存できるようになりました。
(prototypeはデフォルトで設定されているのでわざわざ記述不要)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?