user894145
user894145

Reputation: 1

Truncating in rails

I have this written:

<p><%= resource.description %></p>

However, I'd like to truncate so as to not allow any descriptions over X value. I tried:

<truncate (<%= resource.description %>, limit: 30)>

didn't work.

Thanks.

Upvotes: 0

Views: 51

Answers (1)

Mori
Mori

Reputation: 27779

Try:

<p><%= truncate(resource.description, limit: 30) %></p>

Upvotes: 5

Related Questions