如何在Heroku上使用Sprockets Rails插件?

我刚刚将我的Rails应用程序部署到Heroku,但使用Sprockets插件的Javascripts不起作用。

我明白这一点,因为我的Heroku应用程序是只读的,Sprockets不起作用。 我发现这个sprockets_on_heroku插件应该可以完成这项工作,但我真的不知道如何使用它:

  1. 我在config / environment.rb中添加了config.gem sprockets
  2. 我在.gems文件中添加了sprockets
  3. 我在Heroku上推了这些,并成功安装了Sprockets
  4. 我本地运行script/plugin install git://github.com/jeffrydegrande/sprockets_on_heroku.git并且插件已成功安装

在Heroku上没有任何改变,所以我尝试使用heroku plugins:install git://github.com/jeffrydegrande/sprockets_on_heroku.git插件在Heroku上heroku plugins:install git://github.com/jeffrydegrande/sprockets_on_heroku.git ,它返回了sprockets_on_heroku installed但是然后, heroku restartheroku plugins命令将返回这个:

〜/ .heroku / plugins / sprockets_on_heroku / init.rb:1:未初始化的常量ActionController(NameError)

来自/opt/local/lib/ruby/gems/1.8/gems/heroku-1.8.3/bin/../lib/heroku/plugin.rb:25:in,load’

来自/opt/local/lib/ruby/gems/1.8/gems/heroku-1.8.3/bin/../lib/heroku/plugin.rb:25:in,load!’

来自/opt/local/lib/ruby/gems/1.8/gems/heroku-1.8.3/bin/../lib/heroku/plugin.rb:22:in“each”

来自/opt/local/lib/ruby/gems/1.8/gems/heroku-1.8.3/bin/../lib/heroku/plugin.rb:22:in`load!’

来自/opt/local/lib/ruby/gems/1.8/gems/heroku-1.8.3/bin/../lib/heroku/command.rb:14:in’run’

来自/opt/local/lib/ruby/gems/1.8/gems/heroku-1.8.3/bin/heroku:14

来自/ opt / local / bin / heroku:19:在’load’中

来自/ opt / local / bin / heroku:19

我该怎么办?

凯文

Heroku的作者Jeffry Degrande的链轮回答了我的电子邮件。 我唯一应该做的就是安装插件 git push heroku 以便将文件部署到Heroku。 简而言之:

  1. 在config / environment.rb中添加config.gem sprockets
  2. 在.gems文件中添加sprockets
  3. 运行script/plugin install git://github.com/jeffrydegrande/sprockets_on_heroku.git
  4. 将更改推送到Heroku