【发布时间】:2011-12-27 17:24:11
【问题描述】:
我正在关注this tutorial,但它一直在说“Redcarpet:Module 的未定义方法‘新’”。我的 Gemfile 中有 gem "redcarpet"。失败的代码:
Redcarpet.new(@post.content).to_html
【问题讨论】:
-
只是一个快速的健全性检查......您在更改 gemfile 后运行了“捆绑安装”,对吧?
我正在关注this tutorial,但它一直在说“Redcarpet:Module 的未定义方法‘新’”。我的 Gemfile 中有 gem "redcarpet"。失败的代码:
Redcarpet.new(@post.content).to_html
【问题讨论】:
好的,看起来 Redcarpet 2 已经完全改变了 API。以下作品:
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
:autolink => true, :space_after_headers => true)
raw markdown.render(@post_content.content)
【讨论】:
markdown.render(@post_content.content).html_safe,它也可以。不再喜欢使用raw。