Skip to content

Commit

Permalink
Quick way to show async invalid errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cavis committed Apr 25, 2023
1 parent 0459c14 commit f3be333
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions app/helpers/uploads_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,15 @@ def uploads_resolve_dev_credentials
raise e
end
end

def upload_invalid_messages(rec)
if rec.status_invalid?
rec.status = "complete"
rec.valid?
msgs = rec.errors.full_messages
rec.status = "invalid"
rec.valid?
msgs.present? && msgs.join(", ")
end
end
end
2 changes: 1 addition & 1 deletion app/views/episodes/audio/_error.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<% end %>
</div>

<div class="invalid-feedback">There was a problem processing your audio</div>
<div class="invalid-feedback"><%= upload_invalid_messages(content) || "There was a problem processing your audio" %></div>

<label class="is-invalid">Segment <%= content.position %></label>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/images/_error.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<small class="text-muted">(<%= number_to_human_size(image.size) %>)</small>
</div>

<div class="invalid-feedback">There was a problem processing your image</div>
<div class="invalid-feedback"><%= upload_invalid_messages(image) || "There was a problem processing your image" %></div>

<label class="is-invalid">Image File</label>
</div>
Expand Down

0 comments on commit f3be333

Please sign in to comment.