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

发布于 08-27 00:25 字数 1587 浏览 4 评论 0原文

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

我明白,因为我的 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 插件在 Heroku 上安装插件:install git://github.com/jeffrydegrande/sprockets_on_heroku.git,它返回 sprockets_on_herokuinstalled,但是随后,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:in `load'

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

我应该做什么?

凯文

I just deployed my Rails app to Heroku, but the Javascripts that were using Sprockets plugin don't work.

I understood that, because my Heroku app is read-only, Sprockets won't work. I've found this sprockets_on_heroku plugin that should do the work, but I don't really get how to use it :

  1. I added config.gem sprockets in config/environment.rb
  2. I added sprockets in my .gems file
  3. I pushed these on Heroku and Sprockets was successfully installed
  4. I locally ran script/plugin install git://github.com/jeffrydegrande/sprockets_on_heroku.git and the plugin was successfully installed

Nothing changed on Heroku, so I tried to install the plugin on Heroku with heroku plugins:install git://github.com/jeffrydegrande/sprockets_on_heroku.git, which returned sprockets_on_heroku installedbut then, a heroku restartor a heroku pluginscommand would return this:

~/.heroku/plugins/sprockets_on_heroku/init.rb:1: uninitialized constant ActionController (NameError)

from /opt/local/lib/ruby/gems/1.8/gems/heroku-1.8.3/bin/../lib/heroku/plugin.rb:25:in `load'

from /opt/local/lib/ruby/gems/1.8/gems/heroku-1.8.3/bin/../lib/heroku/plugin.rb:25:in `load!'

from /opt/local/lib/ruby/gems/1.8/gems/heroku-1.8.3/bin/../lib/heroku/plugin.rb:22:in `each'

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

from /opt/local/lib/ruby/gems/1.8/gems/heroku-1.8.3/bin/../lib/heroku/command.rb:14:in `run'

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

from /opt/local/bin/heroku:19:in `load'

from /opt/local/bin/heroku:19

What should I do?

Kevin

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最冷一天2024-09-03 00:25:21

Sprockets on 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

Sprockets on Heroku's author Jeffry Degrande answered my e-mail. The only thing I should have done is to git push heroku after installing the plugin so that the files are deployed to Heroku. In short:

  1. Add config.gem sprockets in config/environment.rb
  2. Add sprockets in .gems file
  3. Run script/plugin install git://github.com/jeffrydegrande/sprockets_on_heroku.git
  4. Push the changes to Heroku
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文