Created
December 11, 2014 02:45
-
-
Save lulalala/78096dfb8df8508f9da8 to your computer and use it in GitHub Desktop.
Bug inside write_attribute
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
# insdie model | |
def write_attribute(attr_name, value) | |
super | |
# Association assignment take effect after super | |
case attr_name | |
when 'admin_editing' | |
pp "Inside write_attribute: #{self.admin_editing}" | |
end | |
end |
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
"Inside write_attribute: true" | |
"Right before save: true" | |
"Inside write_attribute: false" | |
"Right after save: true" |
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
subject = create(:order) | |
subject.admin_editing = true | |
pp "Right before save: #{subject.admin_editing}" | |
subject.save! | |
pp "Right after save: #{subject.admin_editing}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment