How do I... truncate string in an array

Posted by ander163 on Stack Overflow See other posts from Stack Overflow or by ander163
Published on 2010-04-08T14:21:08Z Indexed on 2010/04/08 14:23 UTC
Read the original article Hit count: 274

Filed under:
|

In a ruby on rails app, I build an array of Project Names and project id values, but want to truncate the length of the names. Current code is:

names = active_projects.collect {|proj| [proj.name, proj.id]}

I have tried to add a truncate function to the block, but am getting undefined method for class error.

Thanks in advance - I just cannot wrap my head around this yet.

© Stack Overflow or respective owner

Related posts about rails

Related posts about truncate