Showing attachment in edit view Rails 6 (active storage)

Viewed 215

Situation: I sucessfully upload a file called :physical_copy in my form partial "_a_partial.html.erb", which is used for creating new objects and editing existing objects at the same time

Code:

              <%= f.file_field :physical_copy,
                               required: true,
                               class: 'form-control',
                               value: @tax_relevant_document.physical_copy  %>

New & create works perfectly fine.

Problem: The file is not shown and hence deleted when editing, which is not the planned behavior. I can work around by first downloading and "re-uploading" but this shouldn't be the normal behavior.

Guess: This "value" thing looks awry to me but removal of the attribute didn't help.

I would like:

  1. edit view to show the existing filename in the field as basically value representation
  2. the form should include the existing attachment in the field
0 Answers
Related