Jquery-ui doesn't work on Heroku, but on localhost yes

青春壹個敷衍的年華 提交于 2019-12-06 16:56:25

For anyone coming here from Google - I searched and searched - finally - in my case the answer turned out the be the include directive in app/assets/application.js:

// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
**//= require jquery_ujs**
//= require excanvas.min
//= require bootstrap.min

I added the ** fyi

When you take OUT that line, because you have jquery-rails gem installed (you do have jquery-rails installed right?) then run:

RAILS_ENV=production bundle exec rake assets:precompile:all

At your shell in your Rails app's root directory (I'm spelling everything out here cause a lot of times people don't explicitly state everything in their comments!)

You shouldn't get any errors - it's that :all at the end that was revealing the jquery / jquery_ujs errors.

If you just type:

bundle exec rake assets:precompile

You probably won't get any errors - but jquery won't work either (this is the part that tripped me out).

When I found another comment on SO that said to add :all and it would reveal jquery erros - viola! - it told me stuff wasn't right.

So finally removing the jquery_ujs (which was documented as DON'T REMOVE THIS ON PAIN OF DEATH in other places...) and compiling and then running unicorn as though I'm in production - it works great.

The bonus of course is now that you have your assets compiled you can throw that folder up on Amazon S3, open a CloudFront account, use something like asset_sync gem - and reduce the load even more on Heroku's dynos.

BALLER

In my case i had to delete this plugin from my gem file gem 'sprockets_better_errors'

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