8

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.

Community
  • 1
  • 1
sunnyrjuneja
  • 6,033
  • 2
  • 32
  • 51

1 Answers1

7

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

sunnyrjuneja
  • 6,033
  • 2
  • 32
  • 51
  • 18
    BTW it might just have been that you needed to restart your server. This was the case for me. – callum Oct 20 '13 at 17:49
  • I tried that a few times and it didn't help but I'll keep the advice in mind in case of future strangeness. :) – sunnyrjuneja Oct 20 '13 at 22:16
  • @callum that was the case for me, in the rails console `reload!` didn't do it, I had to stop and restart it. – stevec Jul 02 '23 at 07:40