Hi I have a few chunks of codes which are badly written. I don't know how I should go about doing this.
Firstly there's a link which works fine:
<td><%= link_to 'Show', bidders_assignments_path(:assignment_id => assignment.id), :method => :post %></td>
That will link to the method bidders in assignment_controller:
def bidders
@bids = Bid.where(bidders_params).find_each
#I suspect there's error in the lines below
@bids.each do |bid|
@bidders = User.where(user.id => bid.user_id).find_each
end
end
def bidders_params
params.permit(:assignment_id)
end
Once the @bidders array is filled with data, it will be listed on the view:
<% @bidders.each do |bidder| %>
<tr>
<td><%= bidder.gender %></td>
<td><%= bidder.experience %></td>
<td><%= bidder.expected_salary %></td>
<td><%= bidder.education_id %></td>
<% end %>
I suspect the error is in the filling of @bidders array with data but I can't be sure that's why I'm here. Thanks in advance!
@bids = Bid.where(bidders_params).find_eachbecause it should be passed a blockdef bidders bidders_ids = Bid.where(bidders_params).pluck(:user_id) @bidders = User.where(id: bidders_ids) endNow there's no error but no data get displayed. There's no issue with :@bids = Bid.where(bidders_params).find_eachThe issue is the line after I believe.