aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/plugins
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-09-05 15:39:19 +0100
committerLouise Crow <louise.crow@gmail.com>2013-09-05 15:40:35 +0100
commit2f1cca7df58c93ef7844831af892a716b9b17f48 (patch)
tree2c5fa964a729a38fb338f3105adf6d6ec3f6a97e /vendor/plugins
parent6518bfde0d974092777522c8dd883fd498b2972c (diff)
Don't dirty every attribute in checking for whitespace.
Check to see if the stripped version is different before setting it on the record. If we don't do this, the subsequent call to write_attribute in Globalize3 which uses attribute_will_change! means we're storing versions when there hasn't really been any change.
Diffstat (limited to 'vendor/plugins')
-rw-r--r--vendor/plugins/strip_attributes/lib/strip_attributes.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/vendor/plugins/strip_attributes/lib/strip_attributes.rb b/vendor/plugins/strip_attributes/lib/strip_attributes.rb
index bb93aa9a7..130d10185 100644
--- a/vendor/plugins/strip_attributes/lib/strip_attributes.rb
+++ b/vendor/plugins/strip_attributes/lib/strip_attributes.rb
@@ -8,12 +8,15 @@ module StripAttributes
attribute_names.each do |attribute_name|
value = record[attribute_name]
if value.respond_to?(:strip)
- record[attribute_name] = (value.nil?) ? nil : value.strip
+ stripped = value.strip
+ if stripped != value
+ record[attribute_name] = (value.nil?) ? nil : stripped
+ end
end
end
end
end
-
+
# Necessary because Rails has removed the narrowing of attributes using :only
# and :except on Base#attributes
def self.narrow(attribute_names, options)
@@ -28,7 +31,7 @@ module StripAttributes
attribute_names & only
else
raise ArgumentError, "Options does not specify :except or :only (#{options.keys.inspect})"
- end
+ end
end
end
end