How to use Sprockets Rails plugin on Heroku?

夙愿已清 提交于 2019-12-05 07:30:44

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/2530584/how-to-use-sprockets-rails-plugin-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!