Skip to content
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

Dirty checking is partially broken on Rails 5.2 #2404

Closed
atavistock opened this issue Jul 3, 2019 · 0 comments
Closed

Dirty checking is partially broken on Rails 5.2 #2404

atavistock opened this issue Jul 3, 2019 · 0 comments
Labels

Comments

@atavistock
Copy link

atavistock commented Jul 3, 2019

On Rails 5.1 when a field was changed you would get the key: [FileUpload..., FileUpload] (or whatever Upload) objects when calling changes. In Rails 5.2, changes its only giving back nils for the before and after change information, as in key: [nil, nil]. This is a fairly big problem if you're trying to introspect and make decisions about how the content might have changed.


Test code:

m = ActiveRecord::Migration.new 
m.create_table :lorems do |t|
  t.string :image
end

class Lorem < ActiveRecord::Base
  mount_uploader :image, FileUploader
end

l = Lorem.new
l.image = File.new('/etc/paths')
puts l.changes

Results under Rails 5.1

{"image"=>[#<FileUploader:0x00007fd5ec9d3ce8 @model=#<Lorem id: nil, image: nil>, @mounted_as=:image, @file=nil, @filename=nil, @cache_id=nil, @versions=nil>, #<FileUploader:0x00007fd5ec9d3c20 @model=#<Lorem id: nil, image: nil>, @mounted_as=:image, @file=#<CarrierWave::SanitizedFile:0x00007fd5ec9d1b78 @file="/Users/aaron/src/anomalie/anomalie/public/uploads/tmp/1562175246-39911-0001-8025/paths", @original_filename="paths", @content_type="", @content=nil>, @filename="paths", @cache_id="1562175246-39911-0001-8025", @versions={}, @original_filename="paths", @cache_storage=#<CarrierWave::Storage::File:0x00007fd5ec9d0700 @uploader=#<FileUploader:0x00007fd5ec9d3c20 ...>, @cache_called=nil>>]}

Results under Rails 5.2

{"image"=>[nil, nil]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants