Ruby code is below:
<%= product.advert_text -%>
What script can limit the number of words?
If you want to limit a certain number of words, the easiest way is to split it into a space and then insert the desired number of words back into the line.
<%=product.advert_text.split.slice(0, limit).join(" ") -%>
Since you are working with Rails, you can use the truncate method .
So something like:
<%= truncate(product.advert_text, :length => 20) -%>
:length , , ( :omission - . ).
:length
:omission
Source: https://habr.com/ru/post/1759432/More articles:How to avoid adding jsession id in url? - javaJquery click event not working on div loaded with ajax - jqueryInternationalizing Django with i18n: choosing a language in a template using jQuery - jqueryInstalling multiple packages from one source - javaWhy is LINQ for Entities creating a subquery for me? - sqlWhat do I need to use Markdown in Java Webapp? - javaWordpress - Contact Form 7 Do Not Send To A Specific Address - EmailHibernate annotation issue with JodaTime - javaIs there any way to debug using the visual studio command line? - c ++How to check if current message is first or last in Wordpress - phpAll Articles