6

I'm following this tutorial but it keeps failing saying "undefined method `new' for Redcarpet:Module". I have gem "redcarpet" in my Gemfile. The piece of code that is failing:

Redcarpet.new(@post.content).to_html
unicorn_crack
  • 1,059
  • 1
  • 8
  • 19

1 Answers1

14

Okay, it looks like Redcarpet 2 has completely changed the API. The following works:

markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
    :autolink => true, :space_after_headers => true)
raw markdown.render(@post_content.content)
unicorn_crack
  • 1,059
  • 1
  • 8
  • 19
  • 8
    +1 I prefer to use `markdown.render(@post_content.content).html_safe` which also works. Not a fan of using `raw` anymore. – Substantial Feb 05 '12 at 16:00