0

I'm using Uploadcare to manage images for my Rails app. I can upload images from my computer and from URLs without issue. BUT. I have an edit form for users to edit their entries. The user can change their entry and the image associated with it, but if they don't choose a new image on the edit page and submit the form, there's just not an image. How can I make it so that if the user doesn't choose a new image, the image will just remain the original image?

I'm a Rails newbie, so I suspect there's an easy answer to this, but I can't figure it out!

1 Answers1

0

Got it! Posting the answer for future seekers.

All I needed to include was a "value" in my Uploadcare input field that mapped to the existing photo. So the complete code for the input field is:

<input type="hidden" role="uploadcare-uploader" name="user[photo]" value="<%= @user.photo %>" data-crop="1:1" data-preview-step="true" data-images-only="true" />

Now if a user does not choose a new photo, the old photo remains.