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.
I removed my Gemfile.lock
and did bundle install
again and it worked perfectly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With