Created
March 15, 2023 14:36
-
-
Save avidmaulanas/372b57fe3d98614d1d99fdf35e2b8ed7 to your computer and use it in GitHub Desktop.
make nested attributes work changes on parent save
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
| # == Schema Information | |
| # | |
| # Table name: adjust_quantities | |
| # | |
| # quantity_in_stock :int | |
| class AdjustQuantity | |
| attr_accessor :adjust_quantity | |
| def adjust_quantity=(val) | |
| # method attribute_will_change! for trigger callbacks from parent save | |
| attribute_will_change!(:quantity_in_stock) unless val == @adjust_quantity | |
| @adjust_quantity = val | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment