Arel
Arel

Reputation: 3938

Is there a way to use Simple_format and truncate together?

My best guess is that I need to write a new method that does simple_format and truncate, but I'm not really sure how to do that, or if it's necessary.

Here is an example of how I'm trying to use it now:

<%= simple_format truncate(recap.body, length: 500, separator: ' ') { link_to '(read more)', recap} %>

Upvotes: 0

Views: 165

Answers (1)

LHH
LHH

Reputation: 3323

Try this -

<%= simple_format truncate((h(recap.body) + link_to("read more", recap_path(recap))), length: 500, separator: ' ') %>

it should work for your scenario

Upvotes: 2

Related Questions