Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails & Redcarpet: uninitialized constant Redcarpet::Render when used in ApplicationHelper

I'm following along the RailsCasts episode for Syntax Highlighting Revised. I updated my ApplicationHelper to look like so:

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. I've originally didn't include require 'redcarpet' but I followed the instructions on here but it didn't help.

like image 414
sunnyrjuneja Avatar asked Feb 03 '13 06:02

sunnyrjuneja


1 Answers

I removed my Gemfile.lock and did bundle install again and it worked perfectly.

like image 186
sunnyrjuneja Avatar answered Oct 17 '22 13:10

sunnyrjuneja