从Ruby on Rails应用程序运行phantomjs

Jus*_*zer 7 ruby command-line ruby-on-rails ruby-on-rails-3 phantomjs

我对使用Phantomjs很感兴趣,我想从我的Ruby on Rails应用程序运行它.但是,这是一个命令行工具(即我需要phantomjs rasterize.js http://raphaeljs.com/polar-clock.html clock.png在我的终端中运行一些东西).我如何从我的应用程序执行命令行工具?

Mat*_*att 8

在ruby代码中使用反引号,例如:

output = `phantomjs rasterize.js http://raphaeljs.com/polar-clock.html clock.png`
Run Code Online (Sandbox Code Playgroud)