Skip to content

Instantly share code, notes, and snippets.

@lulalala
Created December 11, 2014 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lulalala/78096dfb8df8508f9da8 to your computer and use it in GitHub Desktop.
Save lulalala/78096dfb8df8508f9da8 to your computer and use it in GitHub Desktop.
Bug inside write_attribute
# 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
"Inside write_attribute: true"
"Right before save: true"
"Inside write_attribute: false"
"Right after save: true"
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