The internal carrier wave defines (overrides) the ActiveRecord getter/setter in the loader column ( translated_xliff )
Now every time you call the setter job.translated_xliff = 'foo' method (as mentioned by Bensie ), it uses the ActiveRecord::Dirty _will_change! for notification of change of object
and then CarrierWave caches the supplied file
Here is your script
job.translated_xliff => uploader job.changed? => false job.translated_xliff = "foo"
Now here's the problem, before Carriewave starts caching the file, it performs a basic check like this
new_file = CarrierWave::SanitizedFile.new(new_file) unless new_file.empty?
empty? used to determine the supplied value (in your case it is foo ) is Path or file , and this is not one of the two in your case, and therefore the file is never a cache, but the object is marked as changed
and therefore you get it
job.changed? => true
Now, calling the job.translated_xliff method when you call job.translated_xliff , pull the file out of the repository since the provided value has never been cached, you can see that it is working on here
Therefore, I mention in the comment. If you want to achieve something like this, perhaps you can check it with an identifier and decide if it has changed
job.translated_xliff.identifier == "foo"
Just a suggestion :)
Hope for this help
source share