lib/preformatter.rb in preformatter-0.7.0 vs lib/preformatter.rb in preformatter-0.7.1
- old
+ new
@@ -63,15 +63,15 @@
end
end
end
end
- def remove_extra_white_spaces(*args)
+ def remove_extra_white_spaces(*args)
args.each do |field|
- before_validation do |record|
+ before_save do |record|
attribute = record.send("#{field.to_s}")
- attribute = attribute.strip.gsub(/[ ]+/, ' ') unless attribute.nil?
- attribute
+ attribute.strip! if !attribute.nil? and !attribute.strip!.nil?
+ attribute.gsub!(/[ ]+/, ' ') if !attribute.nil? and !attribute.gsub!(/[ ]+/, ' ').nil?
end
end
end
end
\ No newline at end of file