undefined method `length’ for Enumerable Enumerator on text_helper.rb:50:in `truncate’
With rails 2.0.2 and ruby 1.8.7 you can find this error using rails truncate helper
To solve this problem, paste this code in your enviroment.rb (eof).
module ActionView module Helpers module TextHelper def truncate(text, length = 30, truncate_string = "...") if text.nil? then return end l = length - truncate_string.chars.to_a.size (text.chars.to_a.size > length ? text.chars.to_a[0...l].join + truncate_string : text).to_s end end end end
Have a nice day!
Thank you.
Fixed my Redmine installation havoc with this enlightenment.
Thank you, helped with redmine also
Thanks so much this code make posible run some old software based on ruby on rails thanks a lot man
Woo, that fixed it. Thank you 😉
Thank you for sharing this, nice quick fix.
Hey…
Nice tip.
Thanks!
Thanks alot, on Ubuntu 9.04 (gems from src) this fix work ok.
I was having the same symptom with Warehouse and although I don’t know how to get the error this fix worked for it. Thanks!
Thanks for posting the fix.
Thanks.
It really helped me.
Thanks, fixed a problem we were having with Redmine 0.7.3 on Ubuntu 9.10 … at least long enough for us to upgrade to 10.04 in due course anyway.
Did you know that USA and Europe blocked Wikileaks? What do you think about it?
Thank you
I do not know who is right. I’ll never know. But I know that I hate blocks.
Thank you for sharing this, nice quick fix.
Thanks!
I am working on an old rails 2.0.2 project and i just wanted to say: Thanks a lot!
Thank you so much..!
Just to say, THANK YOU!!!!!!!!!!!!!!!!!