Skip to content

Commit

Permalink
Wow, what a snafu. Object.present? didn't perform as expected.
Browse files Browse the repository at this point in the history
What I get for writing my own helpers similar but not identical to rail 3 :)
  • Loading branch information
sudara committed Feb 8, 2012
1 parent 4235e60 commit 278b8e3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def track_name_for(asset, length=40)
# in the middle of an entity ex.: truncate("this & that",9) => "this &am..."
# though it will not be the exact length.
def awesome_truncate(text, length = 30, truncate_string = "...")
return unless text.present?
return if text.blank?
l = length - truncate_string.mb_chars.length
text.mb_chars.length > length ? text[/\A.{#{l}}\w*\;?/m][/.*[\w\;]/m] + truncate_string : text
end
Expand Down

0 comments on commit 278b8e3

Please sign in to comment.