質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

0回答

345閲覧

【Rails】押していないボタンが押したことにされてしまう

asatosi

総合スコア23

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2020/09/24 21:03

イメージ説明Rails でシステムを作成しています。

1レコード目のボタン『編集』を押すと、ボタン『予約URLを一括送信』を押下したことになってしまいます。
2レコード目のタン『編集』を押すと、編集処理が実施できます。

Chrome Developerで確認すると、
1レコード目のボタン『編集』は

<td style="white-space:nowrap;">   <div class="position-in-the-cell2">     <input type="submit" value="編集">   </div> </td> ですが、 2レコード目のボタン『編集』は <td style="white-space:nowrap;">   <div class="position-in-the-cell2">     <form class="button_to" method="get" action="/sellers/4/edit">       <input type="submit", value="編集">     </form>   </div> </td> です。

どうすれば、1レコード目のボタン『編集』を押しても、『編集』できるようになるでしょうか?

ruby:index.html.erb

1<% if current_seller.admin_flag %> 2 <br> 3 <h3>『取扱者』管理ページ</h3> 4 <br> 5 <p>『管理者フラグ』が立っているのが、『管理者』、立っていないのが『取扱者』です。</p> 6 <p>ボタン『反転』をクリックすると、『管理者フラグ』を『ON/OFF』します。</p> 7 <p>『管理者』は全部の操作が可能ですが、『取扱者』は一部の操作のみが可能です。</p> 8 <br> 9 <p>チェックボックスでレ点がついている状態で、ボタン『一括送信』を押下すると、『管理者』/『取扱者』に『予約用URL』がメールされます。</p> 10<% else %> 11 <br> 12 <h3>『取扱者』情報ページ</h3> 13<% end %> 14<br> 15<%= form_tag(mail_all_path, method: 'get') do %> 16 <div class="table-responsive overflow-y:auto"> 17 <table class="table table-striped table-bordered table-hover table-width"> 18 <thead> 19 <tr> 20 <% if current_seller.admin_flag %> 21 <th style="white-space:nowrap;"><div class="position-in-the-cell1"> </div></th> 22 <th style="white-space:nowrap;"><div class="position-in-the-cell1">編集</div></th> 23 <th style="white-space:nowrap;"><div class="position-in-the-cell1">削除</div></th> 24 <% end %> 25 <th style="white-space:nowrap;"><div class="position-in-the-cell1">取扱者</div></th> 26 <th style="white-space:nowrap;"><div class="position-in-the-cell1">管理者フラグ</div></th> 27 <th style="white-space:nowrap;"><div class="position-in-the-cell1">予約用URL</div></th> 28 <th style="white-space:nowrap;"><div class="position-in-the-cell1">貸出枚数</div></th> 29 </tr> 30 </thead> 31 32 <tbody> 33 <% @sellers.each do |seller| %> 34 <tr> 35 <% if current_seller.admin_flag %> 36 <td style="white-space:nowrap;"><div class="position-in-the-cell2"><%= check_box_tag 'sellers[]',seller.id %></div></td> 37 <td style="white-space:nowrap;"><div class="position-in-the-cell2"><%= button_to '編集', edit_seller_path(seller), {method: "get"} %></div></td> 38 <td style="white-space:nowrap;"><div class="position-in-the-cell2"><%= button_to '削除', seller_path(seller), {method: "delete"} %></div></td> 39 <% end %> 40 <td style="white-space:nowrap;"><div class="position-in-the-cell2"><%= seller.name %></div></td> 41 <td style="white-space:nowrap;"><div class="position-in-the-cell2"> 42 <% if seller.admin_flag %> 43 ☑️ 44 <% else %> 45 - 46 <% end %> 47 </div></td> 48 <td style="white-space:nowrap;"><div class="position-in-the-cell2"><%= "https://#{@host_with_port}/registers/#{seller.id}/new" %></div></td> 49 <td style="white-space:nowrap;"><div class="position-in-the-cell2"><%= seller.rental_tickets %></div></td> 50 </tr> 51 <% end %> 52 </tbody> 53 <% if current_seller.admin_flag %> 54 <p><%= submit_tag "予約URLを一括送信" %></p> 55 <% end %> 56 </table> 57 </div> 58<% end %> 59<div class="form-group"> 60 <%= button_to '戻る', :back, method: :get %> 61</div> 62![イメージ説明](29ba60d3fa853f70dc32a536a33af2ef.png)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問