首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rails & Redcarpet:在ApplicationHelper中使用时未初始化的常量Redcarpet::Render

Rails & Redcarpet:在ApplicationHelper中使用时未初始化的常量Redcarpet::Render
EN

Stack Overflow用户
提问于 2013-02-03 14:55:30
回答 1查看 3.5K关注 0票数 6

我正在关注Syntax Highlighting Revised的RailsCasts一集。我更新了我的ApplicationHelper,如下所示:

代码语言:javascript
复制
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

但是,我的web应用程序返回

代码语言:javascript
复制
Routing Error

uninitialized constant Redcarpet::Render

Try running rake routes for more information on available routes. 

我使用的是Rails 3.2.11,Redcarpet在rails控制台中响应良好。我最初没有包含require 'redcarpet',但我遵循了here上的说明,但它没有帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-12 04:40:59

我取下我的Gemfile.lock,然后再做一次bundle install,它工作得很好。

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14670184

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档