New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upload removed when update without file field #2362
Comments
Having the same issue, extremely frustrating. Carrierwave will delete the existing upload unless you put it into the file selection box. Basically, editing a model record with a Carrierwave upload results in the upload being deleted unless you re-upload the file during the edit. Don't know how this bug came about, and I can't find a workaround (been trying for hours). |
Hello, I'm having the same issue and I would like to know if there is any work around or fix I can apply to solve this problem? I'm on version 1.2.0 Thanks |
Finally, by simply skipping the field if it is "empty", the file is not removed anymore. This workaround is ok with me! |
What do you mean by "skipping the field if it is empty"? Do you mean a model validation, controller, what? How are you determining if it is "empty"? |
Well, in fact if you do select the file in the html form should contain an image object. If you do NOT select a file, the field for the file will only contain a string with the filename of the actual file. So, to make sure my file is not deleted when I save my changes, I do something like this on the update action of my controller
Doing this, this field is skipped when the save action is done. Hope this helps! |
This is not supposed to happen, what do you have in your uploader and model? |
@mshibuya In my case it was connected to the cache field. If I have a hidden field for the In my case I fixed it by only sending the - if f.object.image_cache
= f.input :image_cache, as: :hidden I hope it helps to find the bug. |
Sorry for getting back late, this is dup of #2412 which was already fixed. |
Hi,
I have a uploader for "img" field in activerecord. If this field isn't used on my form carrierwave remove image into the database.
Here's an example :
If this
img
input isn't present, carrierwave clear this field into database and if i remove from controller the private params of this field. I cannot upload but if he's already an image uploaded, carrierwave remove the image without permission...I use rails (5.2.2) with carrierwave (1.3.0).
It's a bug with carrierwave ?
The text was updated successfully, but these errors were encountered: