[英]Rails & Redcarpet: uninitialized constant Redcarpet::Render when used in ApplicationHelper
I'm following along the RailsCasts episode for Syntax Highlighting Revised . 我正在关注语法高亮修订的RailsCasts剧集。 I updated my ApplicationHelper to look like so:
我更新了我的ApplicationHelper,看起来像这样:
require 'redcarpet'
module ApplicationHelper
class HTMLwithPygments < Redcarpet::Render::HTML
def block_code(code, language)
Pygments.highlight(code, lexer:language)
end
end
def markdown(text)
renderer = HTMLwithPygments.new(hard_wrap: true, filter_html: true)
options = {
autolink: true,
no_intra_emphasis: true,
fenced_code_blocks: true,
lax_html_blocks: true,
strikethrough: true,
superscript: true
}
Redcarpet::Markdown.new(renderer, options).render(text).html_safe
end
end
However, my web app returns 但是,我的网络应用程序返回
Routing Error
uninitialized constant Redcarpet::Render
Try running rake routes for more information on available routes.
I'm using Rails 3.2.11 and Redcarpet responds fine in rails console. 我正在使用Rails 3.2.11并且Redcarpet在rails控制台中做出了很好的响应。 I've originally didn't include
require 'redcarpet'
but I followed the instructions on here but it didn't help. 我原本没有
require 'redcarpet'
但是我按照这里的说明进行了操作但没有帮助。
我删除了我的Gemfile.lock
并再次bundle install
,它运行得很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.