Given an ActiveRecord model that has a mount_uploadcare_file attribute, a Uploadcare::FileApi.store_file is called on every save even when the mount_uploadcare_file attribute has not changed.
I would not expect a network request to be triggered when saving a model when the attribute hasn't changed.
I presume this could be easily fixed by checking if the attribute has changed and only then making the API call, but perhaps the current behavior is handling some edge case I am not aware of.
Describe the bug
Given an ActiveRecord model that has a
mount_uploadcare_file
attribute, aUploadcare::FileApi.store_file
is called on every save even when themount_uploadcare_file
attribute has not changed.I would not expect a network request to be triggered when saving a model when the attribute hasn't changed.
The culprit seems to be:
https://github.com/uploadcare/uploadcare-rails/blob/428a7e64153449b85e587c2aedf9f6df130b8cb8/lib/uploadcare/rails/active_record/mount_uploadcare_file.rb#L50
and
https://github.com/uploadcare/uploadcare-rails/blob/428a7e64153449b85e587c2aedf9f6df130b8cb8/lib/uploadcare/rails/active_record/mount_uploadcare_file.rb#L34-L40
I presume this could be easily fixed by checking if the attribute has changed and only then making the API call, but perhaps the current behavior is handling some edge case I am not aware of.