Я могу запустить jQuery на локальном производстве, выполнив rails s -e production
, но когда тот же проект развернут в Heroku, jQuery не работает, и я получаю сообщение об ошибке в консоли, которое говорит
"Uncaught ReferenceError: $ не определено"
. Я не использую Turbolinks, поэтому я не думаю, что мне нужно что-то делать, кроме
$(document).ready(function() {
//everything js goes here });
Нормальный JavaScript работает, хотя.
Я зарегистрировался в консоли на Chrome с помощью $("#element-id")
, и он дал подробную информацию об элементе, поэтому я думаю, что jQuery загружается. Или консоль Chrome по умолчанию имеет jQuery?
My application.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require Chart.min
//= require_tree .
Разве местная производственная среда не должна быть такой же, как у Heroku? Почему поведение Heroku и местной производственной среды отличается?