0

I use simple_form for handling forms & CarrierWave gem for handling image upload in my application.

Sometimes when submitting the form, CarrierWave gives some errors regarding images, such as: (Files looks like to be another format etc).

After error, all my selected images inside file_field :image fields gets empty/null and I have to select them one by one again.

I usually have 30+ nested forms and 30+ image uploads and I use nested_forms to add each image

How can I prevent the form to empty/null file_field :image fields if form has some errors.

Rubioli
  • 685
  • 6
  • 34

1 Answers1

1

you need to add a hidden field called image_cache

<`%= f.hidden_field :image_cache %>`

You can find this information on the Carrierwave Github page.

d3vkit
  • 1,942
  • 1
  • 24
  • 36
EJAg
  • 3,210
  • 2
  • 14
  • 22