ruby-on-railsrubytruncatehtml-safe

Are truncate and raw mutually exclusive methods in ruby?


I am trying to do this truncate raw(@some_text), length: 300 . When the text exceeds the limit of 300 characters I see html tags in the text.

I need to truncate and implement html(tags prepended and appended) properties in the text. Is there any other way to do the same? Thanks in Advance.


Solution

  • This should work raw(@some_text.slice(0,300))