2

I have a field Rich text in contentful that I try to render, it's a ordered list. I installed the gem rich-text-renderer [ https://github.com/contentful/rich-text-renderer.rb ] but I don't get how to render the Rich text, is anyone having an example, a tuto or could help me on this point ?

In my view I call the field like this :

<% tools = contentful.entries(content_type:'tools',include: 2)%>

but can't display the field called test in the right way

Dips
  • 109
  • 1
  • 10

1 Answers1

0

Install Contentful Rich Text Renderer

gem 'rich_text_renderer', '~> 0.2.1'

Run

bundle install

Create a renderer in your Controller

@renderer = RichTextRenderer::Renderer.new

Then use it in your view

<% tools = contentful.entries(content_type:'tools', include: 2)%>
<% tools.each do |tool| %>
  <div class="contentful_product">
    <h1><%= tool.title %></h1>
    <%= @renderer.render(tool.description).html_safe %>
  </div>
<% end %>
Sergey
  • 367
  • 4
  • 11