> hey folks, > I migrated to 2.1 from 2.0.2, turned on the partial_update > functionality, and specs started to fail. It seems that calling > 'save_without_validation!' on an existing object does not trigger the > save_with_dirty! method.
Why are you calling save_without_validation!? If you want to save without validations the 'public' api is: @object.save(false) The bang seems counter-intuitive? > The path is a bit convoluted, but when save_without_validation! is > called... it calls: > ActiveRecord::Base#update method -> then is overloaded by > ActiveRecord::Dirty#update_with_dirty, which does not clear out the > changed attributes. > > adding a patch like the one pasted at the bottom of this msg fixes the > issue. > > > I'm not sure if this is the right fix or not. It seems that calling > save_without_validation! should still call the save_with_dirty! > method, just like save! calls the save_with_dirty! method. The fact > that it calls the update_with_dirty might just be 'luck'? > > > Thanks, > Adam > > > **PATCH** > > # HACK: why does this not work if I chain it from within the module > Dirty? > # It doesn't seem to pick it up if I use update_with_dirty_with_patch > # and *_without_patch.... but this works as it is patched in after > # ActiveRecord::Base has been extended with ActiveRecord::Dirty > module ActiveRecord > class Base > def update_with_patch > update_without_patch > #FIX: make sure the changed attributes are cleared out after a > successful update!!! > changed_attributes.clear rescue nil > end > alias_method_chain :update, :patch > > end > end > > > > > > > -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
