Fix deprecation warnings in Rails 5.1 #44
Merged
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.
There are tons of deprecation warnings currently in Rails/AR 5.1. This removes the warnings while still passing specs. However, it introduces some questionable changes to achieve this.
There are two problems:
attr_will_change!
(see Check for forced attribute changes rails/rails#27963). To get around this, I've overriddenhas_attribute?
to make locale accessors (title_en
etc) act like real attributes. We can't actually define them all since the list of locales is open-ended.changes
from within after save callbacks. This conflicts with code used to supportprevious_changes
in the Mobility Dirty backend module. This is fixed using abefore_save
hook rather than achanges_applied
override, but this may fail to work as expected if the model callsprevious_changes
in anotherbefore_save
callback added after this.The first solution is ok I think for now, the second one may be more problematic but at least is limited to
previous_changes
only.