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

Model changed? still returns true after being synchronized #123

Closed
jturkel opened this issue Jan 17, 2014 · 2 comments
Closed

Model changed? still returns true after being synchronized #123

jturkel opened this issue Jan 17, 2014 · 2 comments

Comments

@jturkel
Copy link
Contributor

jturkel commented Jan 17, 2014

After importing models using the synchronize option calling model.changed? still returns true e.g.

models = [MyModel.new(id: 777)]
MyModel.import(models, validate: false, synchronize: models)
puts "Changed: #{models.first.changed?}"

Looks like a pretty straightforward fix by adding instance.changed_attributes.clear in synchronize.rb. I'd be happy to put together a pull request if you agree this is a bug.

@zdennis zdennis closed this as completed in f1c1b0a Mar 5, 2014
zdennis added a commit that referenced this issue Mar 5, 2014
@zdennis
Copy link
Owner

zdennis commented Mar 13, 2014

activerecord-import 0.5.0 has been pushed to rubygems with this in there. Thanks again!

@zflat
Copy link

zflat commented Dec 21, 2014

In rails 4.1 and 4.2 I have been getting errors like:

#Class:0x00000002e2ead0#test_#import with :synchronize option synchronizing on destroyed records with explicit conditions_reloads data for existing in-memory instances:
NoMethodError: undefined method changed_in_place_from?' for 1:Fixnum /...j/activerecord-import/test/import_test.rb:160:inblock (4 levels) in <top (required)>'

#Class:0x00000002e2ead0#test_#import with :synchronize option synchronizing on destroyed records with explicit conditions_reloads data for existing in-memory instances:
NoMethodError: undefined method `each' for nil:NilClass

#Class:0x00000002e81438#test_.synchronize_reloads data for the specified records:
NoMethodError: undefined method `changed_in_place_from?' for 1:Fixnum

#Class:0x00000002e81438#test_.synchronize_reloads data for the specified records:
NoMethodError: undefined method `each' for nil:NilClass

#Class:0x00000002e81438#test_.synchronize_the synchronized records aren't dirty:
NoMethodError: undefined method `changed_in_place_from?' for 1:Fixnum

#Class:0x00000002e81438#test_.synchronize_the synchronized records aren't dirty:
NoMethodError: undefined method `each' for nil:NilClass

#Class:0x00000002e2bc40#test_#import with :synchronize option synchronizing on new records with explicit conditions_reloads data for existing in-memory instances:
NoMethodError: undefined method `value_before_type_cast' for 1:Fixnum

Changes to #synchronize fixes this for rails 4.1, but breaks it for rails 3.2.
See my fork at https://github.com/zflat/activerecord-import/tree/issue123-sync

gunlawsguy1 added a commit to gunlawsguy1/activerecord-import that referenced this issue Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants