入力フォームから、imgモデルの:id '33'を更新したいです。
更新アクションでのエラーです。
ArgumentError wrong number of arguments (given 0, expected 1) @img.update(image_update_params) if @img.update →此処で引数が合わないと出ます。 flash[:success] = "Profile updated" redirect_to :action => 'edit' end
ビュー
<%= form_for @img, url: {controller: 'temps', action: 'update'} do |f| %> <%= f.hidden_field :img_count, :value => '1' %> <%= f.submit "決定" %> <% end %>
コントローラ
def edit @img = Img.find(33) end def update @img = Img.find(33) @img.update(image_update_params) if @img.update flash[:success] = "Profile updated" redirect_to :action => 'edit' end end private def image_update_params params.require(:img).permit(:img_count).merge(user_id: current_user.id) end
エラーが表示される時に、下部に入力フォームのパラマスが表示されています。
これらは引数ではないのでしょうか?
入力フォームのimg_countは認識されてないという事なのでしょうか?
Request Parameters: {"utf8"=>"✓", "_method"=>"patch", "authenticity_token"=>"UMuA/asxX1sXZ9xickZjTm0cENgCbsFylA3F9Ve4aShNkC4GnTAuKIbVzKkY97J8PYoyn9UVhe9k5TfOpm67mQ==", "img"=>{"img_count"=>"1"}, "commit"=>"決定", "id"=>"1"}
初歩的な質問で本当に申し訳ないです。
どうぞよろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/07 00:52