2013-02-03 6 views
6

Sto seguendo l'episodio di RailsCasts per Syntax Highlighting Revised. Ho aggiornato il mio ApplicationHelper a guardare in questo modo:Rails & Redcarpet: costante non inizializzata Redcarpet :: Render se utilizzato in 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 

Tuttavia, la mia web app torna

Routing Error 

uninitialized constant Redcarpet::Render 

Try running rake routes for more information on available routes. 

sto usando Rails 3.2.11 e RedCarpet risponde bene in console rotaie. Originariamente non ho incluso require 'redcarpet' ma ho seguito le istruzioni su here ma non è stato d'aiuto.

risposta

7

Ho rimosso il mio Gemfile.lock e l'ho fatto di nuovo bundle install e ha funzionato perfettamente.

+17

BTW potrebbe essere solo che è necessario riavviare il server. Questo è stato il mio caso. – callum

+0

L'ho provato un paio di volte e non è stato d'aiuto, ma terrò presente il consiglio in caso di future stranezze. :) – sunnyrjuneja

Problemi correlati