module ActiveModel::Validations::HelperMethods

Public Instance Methods

strip_attributes(options = {}) click to toggle source

Strips whitespace from model fields and converts blank values to nil.

# File lib/strip_attributes.rb, line 5
def strip_attributes(options = {})
  StripAttributes.validate_options(options)

  before_validation(options.slice(:if, :unless)) do |record|
    StripAttributes.strip(record, options)
  end
end