注:更新された質問については、このリンクを参照してください。私は、いつか他の試した後、より簡潔にするために私の質問を言い換えている:Ruby on Rails single form to update multiple records using loopフォームを介したRuby on Railsのマルチテーブルクエリ
私は特定のプロジェクトのために、すべての入札者を表示するページがあり、次のようにbidders.html.erbがある:
<div id="titlebar" class="single submit-page">
<div class="container">
<div class="col-lg-10">
<h2><i class="fa fa-bell"></i> Bidders</h2>
</div>
<!-- <div class="col-lg-2">
<br>
<button type="button" class="btn btn-primary btn-lg">
<i class="fa fa-list-alt"></i> Find Assignments
</button>
</div>
-->
</div>
</div>
<div class="container">
<!-- Table -->
<div class="col-lg-12">
<p class="margin-bottom-25"> Bids can be viewed or removed below.</p>
<table class="manage-table resumes responsive-table">
<tr>
<th><i class="fa fa-genderless"></i> Gender</th>
<th><i class="fa fa-clock-o"></i> Experience</th>
<th><i class="fa fa-graduation-cap"></i> Education Level</th>
<th><i class="fa fa-money"></i> Expected Salary</th>
<th><i class="fa fa-file-text"></i> Status</th>
<th></th>
</tr>
<!-- Item #1 -->
<tbody>
<% @bidders.each do |bidder| %>
<tr>
<% if bidder.gender == 1 %>
<td>Male</td>
<% else %>
<td>Female</td>
<% end %>
<td><%= bidder.experience %></td>
<td><%= bidder.education.education %></td>
<td><%= bidder.expected_salary %></td>
<td><%= bidder.bid.status %></td>
<td class="action">
<a href="#"><i class="fa fa-eye-slash"></i> Hide</a>
<a href="#" class="delete"><i class="fa fa-remove"></i> Delete</a>
</td>
</tr>
<!-- Item #1 -->
<% end %>
</tbody>
</table>
</div>
</div>
そして、私のapplication_controller.rbは次のとおりです。
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def bidders
bidders_ids = Bid.where(bidders_params).pluck(:user_id)
@bidders = User.where(id: bidders_ids)
end
def after_sign_in_path_for(resource)
assignments_path #your path
end
end
データベース設計は、多かれ少なかれ、以下で示されている。問題は、私ができるように、フォームにbidders.html.erbスクリプトを変換して助けを必要とするということである
特定のプロジェクトの所有者はbidder.bid.statusをランキング番号に編集して複数の入札者を受け入れ、ランク付けします。
ユーザーは入札可能であり、他のユーザーが入札するプロジェクトを作成することもできます。
: http://stackoverflow.com/questions/38900349/ruby-on-rails-single-form-to-update-multiple-records-using-loop がより良い私の質問を表し、 – Benjamin