Obserwuję odcinek RailsCasts dla Syntax Highlighting Revised. Zaktualizowałem moją ApplicationHelper wyglądać tak:Railsy i Redcarpet: niezainicjowana stała Redcarpet :: Renderowana w 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
Jednak moja aplikacja internetowa zwraca
Routing Error
uninitialized constant Redcarpet::Render
Try running rake routes for more information on available routes.
Używam Rails 3.2.11 i Redcarpet reaguje prawidłowo w konsoli Rails. Początkowo nie zawierałem require 'redcarpet'
, ale postępowałem zgodnie z instrukcjami na here, ale to nie pomogło.
BTW może to oznaczać, że trzeba ponownie uruchomić serwer. Tak było w moim przypadku. – callum
Próbowałem tego kilka razy i to nie pomogło, ale będę miał na uwadze tę poradę w przypadku przyszłej dziwności. :) – sunnyrjuneja