A
A
Alexander Petrov2016-04-06 15:39:28
ruby
Alexander Petrov, 2016-04-06 15:39:28

How to display part of the text?

I understand that the question is very stupid, but for some reason I did not find an answer to it .....(
I have a blog article. I want to preview only, say, 500 characters from the blog article itself. How can I do this?
Output like this: <%=item.body%>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey R, 2016-04-06
@honestua

look at the truncate helper

<%= truncate(item.body, length: 500) %>

R
Roman Mirilaczvili, 2016-04-06
@2ord

Read about Array slice

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question