Module: ActiveModel::Validations::HelperMethods

Defined in:
lib/strip_attributes.rb

Instance Method Summary collapse

Instance Method Details

#strip_attributes(options = {}) ⇒ Object

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



5
6
7
8
9
10
11
# 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