Make sure that the string returned by TextHelper#truncate is actually a...

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
上级 27bb903a
*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]
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册