Active Storage: Best practice to retain/cache uploaded file when form redisplays
for those looking for has_many_attached
solution
https://github.com/rails/rails/issues/35817#issuecomment-484158884
<% if @product.photos.attached? %>
<% @product.photos.each do |ph| %>
<%= f.hidden_field :photos, value: ph.signed_id %>
<% end %>
<% end %>
Here's a solution to make ActiveStorage files persist on form redisplay:
f.hidden_field :image, value: f.object.image.signed_id if f.object.image.attached?
f.file_field :image