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 :
- I added
config.gem sprockets
in config/environment.rb - I added
sprockets
in my .gems file - I pushed these on Heroku and Sprockets was successfully installed
- 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 installed
but the开发者_如何学运维n, a heroku restart
or a heroku plugins
command 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
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:
- Add
config.gem sprockets
in config/environment.rb - Add
sprockets
in .gems file - Run
script/plugin install git://github.com/jeffrydegrande/sprockets_on_heroku.git
- Push the changes to Heroku
精彩评论