Skip to content

Instantly share code, notes, and snippets.

@duyetpt
Created August 3, 2020 07:50
Show Gist options
  • Save duyetpt/b7829aecb23e519d67dcee990ae68479 to your computer and use it in GitHub Desktop.
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
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