-
Notifications
You must be signed in to change notification settings - Fork 463
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
Add support for Rails 5.1+ AR Dirty changes #379
Conversation
…`has_changes_to_save?`, `column_was` to `column_in_database` and `changed` to `changed_attribute_names_to_save`. Check version string for each changes for backward compatibility.
@@ -86,7 +86,7 @@ def has_ancestry options = {} | |||
after_destroy :touch_ancestors_callback | |||
|
|||
if ActiveRecord::VERSION::STRING >= '5.1.0' | |||
after_save :touch_ancestors_callback, if: :saved_changes? | |||
after_save :touch_ancestors_callback, if: :has_changes_to_save? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saved_changes?
and has_changes_to_save?
have different semantics. saved_changes?
is true if there were any changes when an instance was saved last time. has_changes_to_save?
(which is an alias to changed?
) is true if there are unsaved changes.
With this change touch_ancestors_callback is never called, two more tests fail. Tested with AR 5.2.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@khustochka thanks for the insight. It sounds like save_changes?
is the one we till want to use
thank you for diving into this. I'm trying to make some cleanup to make this easier to get fixed |
This is great stuff.
Could you rebase and then help me understand the various methods that you all suggest instead of using Thanks for this PR. It is helping me get up to date with 5.2. ASIDE: I'm looking at replacing |
I do have a branch that uses I did need to revisit this. I've put together #387 instead. Hope that will meet our needs |
from
saved_changes?
tohas_changes_to_save?
,column_was
tocolumn_in_database
andchanged
tochanged_attribute_names_to_save
. Check version string for each changes for backward compatibility.