Ruby on Rails Truncate text - can I use it for a combination of title and content?
- by Quhby
I have
<%=link_to topic.title, topic_path(topic) %
- <%= truncate(topic.description_without_embed, :length=50, :omission ="...") %
But what I really want to do is to truncate both the title and the post to 50 characters. How can this be done?
The output should look something like
Lorem ipsum dolor sit amet, consectetur adipiscing elit. - Curabitur eu dolor est, id pharetra lectus. Phasellus nec feugiat dolor. Curabitur feugiat ultrices leo ut egestas. Nullam nec nisi in ligula feugiat placerat. Ut adipiscing urna consequat tortor euismod pretium. Maecenas eget quam aliquet orci blandit eleifend eu et quam. Donec.
instead of
Lorem ipsum dolor sit amet, consectetur adipiscing elit. - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu dolor est, id pharetra lectus. Phasellus nec feugiat dolor. Curabitur feugiat ultrices leo ut egestas. Nullam nec nisi in ligula feugiat placerat. Ut adipiscing urna consequat tortor euismod pretium. Maecenas eget quam aliquet orci blandit eleifend eu et quam. Donec.
I don't need to use the truncate method, any method would be helpful. Thanks.