: https://github.com/holli/auto_strip_attributes
, , , , . . .
gem "auto_strip_attributes", "~> 1.0"
class User < ActiveRecord::Base
auto_strip_attributes :name, :nick, :nullify => false, :squish => true
end
, before_save. ( .) , .
attributes.each do before_validation do ...
record.send("#{attr_name}=", record.send(attr_name).to_s.strip)
attributes.each do before_validation do ...
record[attribute] = record.send(attr_name).to_s.strip)
setter ( , before_validation). setter , setter.