我尝试在我的 Rails 应用程序中使用 asciidoctor gem。我将其添加到我的 Gemfile
中并进行捆绑安装
。
现在我尝试在 Controller 中使用 asciidoctor:
def show
@article.text = Asciidoctor.render(@article.text)
end
但是我收到一个错误:
uninitialized constant ArticlesController::Asciidoctor
在 Rails 中使用 asciidoctor-gem 的正确方法是什么?
最佳答案
请记住在更改 Rails 自动重新加载路径之外的内容后重新启动服务器(即 app/*
和 config/routes.rb
)。
自 documentation看起来和你的例子一模一样
puts Asciidoctor.render '*This* is http://asciidoc.org[AsciiDoc]!'
我猜,您只是忘记重新启动服务器。
关于ruby-on-rails - 在 Rails 中使用 Asciidoctor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24272873/