aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-01-31 17:55:09 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-01-31 17:55:09 +0000
commit5c0227edc9fe3392a774a52cbeb9ca8cad4a4e65 (patch)
treed60c41b51b4dfcf749f7f85ff00d30d89b27b338
parent27bb903aa068fc61c79bec53a7f4d524e935cf0f (diff)
downloadrails-5c0227edc9fe3392a774a52cbeb9ca8cad4a4e65.tar.gz
rails-5c0227edc9fe3392a774a52cbeb9ca8cad4a4e65.tar.bz2
rails-5c0227edc9fe3392a774a52cbeb9ca8cad4a4e65.zip
Make sure that the string returned by TextHelper#truncate is actually a string, not a char proxy -- that should only be used internally while working on a multibyte-safe way of truncating [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6096 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb2
2 files changed, 3 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 7c04549f50..e4e8a444e6 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Make sure that the string returned by TextHelper#truncate is actually a string, not a char proxy -- that should only be used internally while working on a multibyte-safe way of truncating [DHH]
+
* Added FormBuilder#submit as a delegate for FormTagHelper#submit_tag [DHH]
* TestSession supports indifferent access so session['foo'] == session[:foo] in your tests. #7372 [julik, jean.helou]
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index e60f6c2986..1698598edb 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -35,7 +35,7 @@ module ActionView
def truncate(text, length = 30, truncate_string = "...")
if text.nil? then return end
l = length - truncate_string.chars.length
- text.chars.length > length ? text.chars[0...l] + truncate_string : text
+ (text.chars.length > length ? text.chars[0...l] + truncate_string : text).to_s
end
# Highlights +phrase+ everywhere it is found in +text+ by inserting it into