Last active
September 24, 2019 18:02
-
-
Save anujbiyani/7a7e76255558af57d865e368812dfe75 to your computer and use it in GitHub Desktop.
Tricking PaperTrail into saving attributes that didn't change - problem
This file contains 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
patient_preferences = create( | |
:patient_preferences, | |
health_information_exchange_opt_in: true, | |
health_information_exchange_legal_text_version: 1 | |
) | |
patient_preferences.health_information_exchange_opt_in = true | |
patient_preferences.health_information_exchange_legal_text_version = 2 | |
puts patient_preferences.changes | |
#=> {"health_information_exchange_legal_text_version"=>[1, 2]} | |
# health_information_exchange_opt_in is missing | |
patient_preferences.save! | |
puts patient_preferences.versions.last.object_changes | |
#=> --- | |
#=> health_information_exchange_legal_text_version: | |
#=> - 1 | |
#=> - 2 | |
#=> updated_at: | |
#=> - 2019-08-30 17:57:12.000000000 Z | |
#=> - 2019-08-30 17:57:13.000000000 Z | |
# health_information_exchange_opt_in is missing, so we have to infer it from: | |
puts patient_preferences.versions.first.object_changes | |
#=> --- | |
#=> health_information_exchange_opt_in: | |
#=> - | |
#=> - true | |
#=> health_information_exchange_legal_text_version: | |
#=> - | |
#=> - 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment