ruby-on-rails - 在 Rails 中使用 Asciidoctor

标签 ruby-on-rails ruby rubygems asciidoctor

我尝试在我的 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/

相关文章:

ruby-on-rails - 找不到 HTML2HAML 命令

ruby-on-rails - 如何解决 Nokogiri 解析缓慢的问题

mysql - rails 3.2 + MySQL : Error: Field 'created_at' doesn't have a default value: INSERT INTO

ruby - 如何查看系统中是否安装了 gem?

ruby-on-rails - 在 Ubuntu 9.10 上安装 Rails 的最佳安装指南是什么?

xcode - 使用自制软件安装的 gcc 编译器时发生rails 4 gem 安装错误

ruby-on-rails - 获取 HTTP 错误 RestClient::Unauthorized (401 Unauthorized): Using 'rest-client' gem in rails

ruby-on-rails - `gem install sqlite3` 告诉我 `brew install sqlite3` ,但它似乎已经安装在我的系统上——我该如何解决?

php - 开源在线 IDE

Ruby 只获取/放置字符串?