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

#strip_attributes!(options = {}) ⇒ Object

DEPRECATED: Please use strip_attributes (non-bang method) instead.



15
16
17
18
# File 'lib/strip_attributes.rb', line 15

def strip_attributes!(options = {})
  warn "[DEPRECATION] `strip_attributes!` is deprecated.  Please use `strip_attributes` (non-bang method) instead."
  strip_attributes(options)
end