I have text field where user would be writing recipe of food item. For formatting of text, I just install ckeditor.
Added gem "ckeditor" in gemfile and executed this:
rails generate ckeditor:install --orm=active_record --backend=paperclip
as given in github.com/galetahub/ckeditor.
Then i updated my recipe text area to:
<%= f.cktext_area :recipe, :size => 5, :id => "field-area5", :ckeditor => {:language => "us"} %>
It displays all formatting tools and formats text properly. But when i submit the content and display the output using,
<%= @product.recipe %>
it displays with HTML tags instead of the way i formatted. e.g.
<p><strong>Recipe</strong></p> <h1><span style="font-family:georgia,serif"><em>i dont know anything</em></span></h1>
Can anybody help why this is happening? How to display formatted content? Your help is appreciated.
Thanks.
Have you tried the following?
<%= raw(@product.recipe) %>
Take a look here for further info: http://api.rubyonrails.org/classes/ActionView/Helpers/OutputSafetyHelper.html#method-i-raw
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With