From 5c0227edc9fe3392a774a52cbeb9ca8cad4a4e65 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 31 Jan 2007 17:55:09 +0000 Subject: [PATCH] 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 --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_view/helpers/text_helper.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) 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 @@ def concat(string, binding) 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 -- GitLab