Reputation: 10885
I'm using Rails 4 and come across with very strange problem. That raw and truncate not working properly together.
<%= raw(job.description)%> # working properly
<%= raw(truncate(job.description,:length => 200))%> # Not strip html tags
<%= truncate((raw job.description),:length => 200)%> # Not strip html tags
What the problem is?
Any help please??
Upvotes: 5
Views: 3394
Reputation: 23661
You can make use of truncate
with sanitize
truncate(sanitize(job.description, tags: []), length: 200)
Upvotes: 2
Reputation: 1657
I'm not sure what you are trying to accomplish so simply try
raw job.description.truncate(200)
and\or
(raw job.description).truncate(200)
Upvotes: 20