root_urlに投稿フォームを作り、form_forで情報を渡すとき
更新するとsubmitは反応するのですが
最初の一回目が反応しません。
同じような質問があったのですが、解決できていなくて、同じような状況から突破した方がいましたらぜひご教授いただきたいです。
<div class="product-form"> <%= form_for(@micropost, html:{class: 'form-horizontal'}) do |f| %> <%= render 'shared/error_messages', object: f.object %> <table class="table table-striped table-bordered table-hover product-table"> <tbody> <tr> <th class="product-body">商品名</th> <th class="product-image">画像</th> </tr> <td class="product-body"><%= f.text_field :product, placeholder: "商品名を入力してください" %></td> <td class="product-image"><%= f.file_field :image, accept: 'image/jpeg,image/gif,image/png' %></td> </tbody> </table> </div> <div class="block-form"> <table class="table table-striped table-bordered table-hover"> <tbody> <tr> <th>場所</th> <th>時期</th> <th>詳細情報</th> <th>Action</th> </tr> <%= f.nested_fields_for :blocks, wrapper_tag: :tr do |q| %> <td><%= q.select :place, Block.places.keys, {}, class: 'form-control' %></td> <td><%= q.date_select :date, class: 'form-control' %></td> <td><%= q.text_area :information, placeholder: "入力してください", class: 'form-control' %> <%= q.file_field :picture, accept: 'image/jpeg,image/gif,image/png' %> </td> <td><%= q.remove_nested_fields_link '削除', class: 'btn btn-danger', role: 'button' %></td> <% end %> </tbody> </table> <%= f.add_nested_fields_link :blocks, '情報を追加', class: 'btn btn-primary add-block-btn', role: 'button' %><br> </div> </div> <%= f.submit "作成", class: "btn btn-primary submit" %> <% end %> <script type="text/javascript"> $('#micropost_image').bind('change', function() { var size_in_megabytes = this.files[0].size/1024/1024; if (size_in_megabytes > 5) { alert('Maximum file size is 5MB. Please choose a smaller file.'); } }); </script>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。