Created
August 3, 2020 07:50
-
-
Save duyetpt/b7829aecb23e519d67dcee990ae68479 to your computer and use it in GitHub Desktop.
Only validate state if state change value or will save change to db
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
def self.validates_if_change properity_name, options = {} | |
options = options.merge if: "will_save_change_to_#{properity_name.to_s}?".to_sym | |
validates properity_name, options | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment