-
Notifications
You must be signed in to change notification settings - Fork 120
Fix _changed? BC break and introduce algolia_dirty? method #338
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b3074d9
Add tests to detect change on not index property
julienbourdeau 20ad9d2
Fix attribute_changed? detection
julienbourdeau 9293d65
Introduce algolia_dirty? instance method
julienbourdeau b7c05bb
Check if _changed? is user-defined before calling it in recent Rails …
julienbourdeau 1840b6a
Support Ruby 1.8 for user-defined _changed? method
julienbourdeau 40865e2
Add more tests for change detection
julienbourdeau bc07d06
dont call will_save_change_ method for Ruby 1.8
julienbourdeau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Wouldn't this code essentially always call
#{attr_name}_changed?, since on any random Rails model, callingmodel.respond_to?(:xxx_changed?)returns true for all model attributes?If so, this would essentially nullify #325, which means that on Rails 5.1 this gem would revert to its old behavior i.e. it would start emitting warnings again for all algolia attributes with the same name as a model attribute.
As a reminder, the deprecation warning in Rails 5.1 was:
I believe this warning was removed in Rails 5.2 as they changed the behavior (I guess). But
xxx_changed?still exists and will likely always exist.So unless there is some way to know if
xxx_changedwas defined by the end user, instead of redefined by Rails, I am not sure this fix would work.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.
Yes, I agree. I don't know why I didn't see it myself. I guess after trying a few things, I started ignoring some cases. I was really looking to restore the previous behavior. 😅
I definitely don't want to see those warning in more recent rails version 👍