Skip to content

Instantly share code, notes, and snippets.

@mikecmpbll
Created August 22, 2014 11:03
Show Gist options
  • Save mikecmpbll/cd80a3531b40c3f358b1 to your computer and use it in GitHub Desktop.
Save mikecmpbll/cd80a3531b40c3f358b1 to your computer and use it in GitHub Desktop.
Skip all validations on a particular field in Rails
plain_text_password_validators = User.validators.select { |v| v.attributes.include?(:plain_text_password) }
callback_filters = User._validate_callbacks.select{ |vc| plain_text_password_validators.include?(vc.raw_filter) }.map{ |vc| vc.filter }
callback_filters.each do |cf|
User.skip_callback(:validate, :before, cf)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment