You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I came across this issue while using carrierwave and paper_trail on the same model as despite saving no changes, paper_trail added always a new revision displaying that file has been changed.
However, the value of file was the same so I dig a bit deeper to find what did gone wrong.
You do not need paper_trail to follow up.
Create and update model but do not change anything:
m=MyModel.create()m.update(remove_file: "0")# does nothing
Update model with no changes if file is present:
m=MyModel.create()m.file= <SomeFile>
m.savem.update(remove_file: "0")# saves the same value to `file` column again.
Even there are no changes, every hook is fired which listen on change-events for this column.
In my case this was paper_trail for tracking revisions.
Workaround: Delete param remove_file if it is "0" within controller prior to #update.
The text was updated successfully, but these errors were encountered:
Flauschbaellchen
changed the title
Bug: #update(remove_file: "0") always change model if file is present
Bug: #update(remove_file: "0") always change model if 'file' is present
Jun 27, 2018
I came across this issue while using
carrierwave
andpaper_trail
on the same model as despite saving no changes, paper_trail added always a new revision displaying thatfile
has been changed.However, the value of
file
was the same so I dig a bit deeper to find what did gone wrong.You do not need
paper_trail
to follow up.A little bit of pseudo-code:
Setup model to use carrierwave:
Create and update model but do not change anything:
Update model with no changes if
file
is present:Even there are no changes, every hook is fired which listen on change-events for this column.
In my case this was
paper_trail
for tracking revisions.Workaround: Delete param
remove_file
if it is "0" within controller prior to#update
.The text was updated successfully, but these errors were encountered: