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?

More than 3 years have passed since last update.

<%= form_with do |f| %> updateやcreateが発火/動作しない問題

Posted at

#<%= form_with do |f| %> updateやcreateが発火しない問題
コントロールやモデルに問題があるコードがないのに発火/動作しない...
updateやcreateができない原因は使っているタグ、ビューファイル(html.erb)に問題があるかも

タグ
<div></div>
<table></table>
いっぱいあるけど割愛

##うまく動作しない集

form
<form>#bootstrapで参考しがちなformタグ..これをform_withと併用するとうまく発火しない原因になる
<%= form_with model:@user, local:true do |f| %>
<%= f.label :profile_image %>
<%= attachment_image_tag @user, :profile_image, :fill, 30, 30, fallback: "noimage.png"%>
<%= f.submit %>#submitボタンを押して画面がrenderみたいに遷移する
</form>#form_withを消して<div>で囲もう
tabel
<table>#テーブルタグも同様になる可能性があるあまり使わない方がいい
<%= form_with model:@user, local:true do |f| %>
<%= f.label :profile_image %>
<%= attachment_image_tag @user, :profile_image, :fill, 30, 30, fallback: "noimage.png"%>
<%= f.submit %>
</table>
しっかりとタグで囲もう!!


<%= form_with model:@user, local:true do |f| %>
<div>------------------------------------------------------------------------------------
<%= f.label :profile_image %>
<%= attachment_image_tag @user, :profile_image, :fill, 30, 30, fallback: "noimage.png"%>
<%= f.submit %>
</div>-----------------------------------------------------------------------------------
divで変な囲い方をすると発火しない原因になる
0
0
1

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?