简体   繁体   中英

Javascript works locally, but no longer works when deployed to Heroku. (With turbo links.)

For some reason my javascripts are not working on Heroku. I know that this has something to do with Turbolinks, but I'm not sure what could be causing it.

Gemfile:

gem 'turbolinks', '~> 1.3.0'
gem 'jquery-turbolinks'

As you can see, I am using the query-turbolinks gem. Locally, everything works, but when deployed all of my Javascript is broken as if I haven't loaded my javascripts correctly.

Maybe I need to apply this code to all of my javascripts?

var ready;
ready = function() {

  ...your javascript goes here...

};

$(document).ready(ready);
$(document).on('page:load', ready);

I wonder why it is working in development but not in production...

try with updating this in production.rb

config.assets.compile = true
config.serve_static_assets = true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM