0

I'm trying to use the Redcarpet gem to render markdown on my app and am getting the error wrong number of arguments (0 for 1) on my erb page where I call the render:

<p><%= markdown.render(@wiki.body) %></p>

Here's my application_helper:

module ApplicationHelper
  def markdown(text)
    markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true)
  end
end

Can anyone see where I'm going wrong? I've read a bunch of SO posts on this, but I'm new to this gem.

Liz
  • 1,369
  • 2
  • 26
  • 61

1 Answers1

1

Your helper should look more like this:

module ApplicationHelper
  def markdown(text)
    md = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true)
    md.render(text)
  end
end

and called like so:

<p><%= markdown(@wiki.body) %></p>
Lesleh
  • 1,665
  • 15
  • 24