Skip to content

Instantly share code, notes, and snippets.

@slavone
Created November 29, 2017 14:38
Show Gist options
  • Save slavone/f3505218f206aec3b2433bb11929fbc9 to your computer and use it in GitHub Desktop.
Save slavone/f3505218f206aec3b2433bb11929fbc9 to your computer and use it in GitHub Desktop.
Rails skip validation
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