From 459f7bf38aa196cf4d2d970173b02d88e4a4e75c Mon Sep 17 00:00:00 2001 From: Kuldeep Aggarwal Date: Sat, 19 Apr 2014 01:31:07 +0530 Subject: Fix inconsistent behavior from String#pluralize Before: When calling String#pluralize with count=1 then it returned same string, but with count other than 1, returned new string. After: String#pluralize always return a new string. => Prevent mutation of a string inadvertently. --- activesupport/lib/active_support/core_ext/string/inflections.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/core_ext/string/inflections.rb b/activesupport/lib/active_support/core_ext/string/inflections.rb index 18273573e0..a943752f17 100644 --- a/activesupport/lib/active_support/core_ext/string/inflections.rb +++ b/activesupport/lib/active_support/core_ext/string/inflections.rb @@ -31,7 +31,7 @@ class String def pluralize(count = nil, locale = :en) locale = count if count.is_a?(Symbol) if count == 1 - self + self.dup else ActiveSupport::Inflector.pluralize(self, locale) end -- cgit v1.2.3