Created
November 29, 2017 14:38
-
-
Save slavone/f3505218f206aec3b2433bb11929fbc9 to your computer and use it in GitHub Desktop.
Rails skip validation
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
module ValidationSkipper | |
def skips_validation(attribute, validator) | |
_validators[attribute]&.reject! { |v| v.is_a?(validator) } | |
_validate_callbacks.each do |callback| | |
next unless callback.raw_filter.is_a?(validator) | |
callback.raw_filter.attributes.delete(attribute) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment