Skip to content

Commit

Permalink
Fix problem report page unable to be loaded due to deleted users (#346)
Browse files Browse the repository at this point in the history
* Add nil user check for problem report page
  • Loading branch information
chrisjwelly authored Aug 9, 2019
1 parent 5f908ac commit be69d01
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/views/problem_reports/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
<% @problem_reports.each do |pb| %>
<tr>
<td><%= pb.id %></td>
<td><%= User.find(pb.reporter_user_id)&.username %></td>
<td><%= pb.reporter_user_id == nil \

This comment has been minimized.

Copy link
@indocomsoft

indocomsoft Aug 18, 2019

Contributor

More idiomatic would probably be User.where(id: pb.reporter_user_id)&.username || "(Deleted member)"

? "(Deleted member)" \
: User.find(pb.reporter_user_id)&.username %></td>
<td><%= Place.find(pb.place_id).name %></td>
<td><%= pb.computer_number %></td>
<td><%= pb.description %></td>
Expand All @@ -47,7 +49,11 @@
<%= text_area_tag(:remarks, "", size: "20x2", class: "form-control") %> <br>
<%= submit_tag('Change Remark', :class=>'btn btn-large btn-light problem-report-btn') %>
<% end %></td>
<td class="last-updated-by"><%= User.find(pb.last_update_user_id)&.username %></td>
<td class="last-updated-by">
<%= pb.reporter_user_id == nil \
? "(Deleted member)" \
: User.find(pb.last_update_user_id)&.username %>
</td>
<td class="last-updated-at"><%= pb.updated_at.strftime("%d %b %Y %H:%M") %></td>
</tr>
<% end %>
Expand Down

0 comments on commit be69d01

Please sign in to comment.