Heroku jQuery JavaScript 库未加载 - 404 错误
Posted
技术标签:
【中文标题】Heroku jQuery JavaScript 库未加载 - 404 错误【英文标题】:Heroku jQuery JavaScript library not loading - 404 error 【发布时间】:2017-05-28 05:33:53 【问题描述】:Heroku 和我的生产环境未加载 jQuery javascript 库,导致以下“加载资源失败:服务器响应状态为 404(未找到)”。
我所做的所有研究都指向资产管道问题,但我已确认资产正在本地预编译并交付给 Heroku。
我已经执行/测试了以下内容,但仍有问题。
-
在 application.js 中安排了我的资产订单
更改了 production.rb:config.assets.compile = true ,而不是默认的 config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
运行命令:rake assets:precompile 然后 git push heroku master
运行命令:RAILS_ENV=production bundle exec rake assets:precompile
运行命令:heroku run rake assets:precompile --app appName
添加了 heroku 文档中提到的 gem 'rails_serve_static_assets'
预编译生产资产并在 Heroku 上推送和编译。 RAILS_ENV=production bundle exec rake assets:precompile
在 Heroku 中调试:确认已加载到公共/资产的预编译资产
$ heroku 运行 bash
$ ls public/assets
在我的控制台中仍然收到 404 错误“加载资源失败:服务器响应状态为 404(未找到)”专门命名 Jquery javascript 库。
在我做错的事情上遇到障碍。感谢您提供任何帮助。
虽然我收到 404 错误,但我的问题似乎与没有答案的问题类似。
Jquery not working in Production & Heroku but works perfectly well in development
代码
应用程序.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require map_theme/vendor/modernizr.custom
//= require map_theme/vendor/matchMedia
//= require map_theme/vendor/bootstrap
//= require map_theme/vendor/jquery.storageapi
//= require map_theme/vendor/jquery.easing
//= require map_theme/vendor/animo
//= require map_theme/vendor/jquery.slimscroll.min
//= require map_theme/vendor/screenfull
//= require map_theme/vendor/jquery.localize
//= require map_theme/demo/demo-rtl
//= require map_theme/vendor/index
//= require map_theme/vendor/jquery.classyloader.min
//= require map_theme/vendor/moment-with-locales.min
//= require map_theme/app
生产.rb
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_files = true
config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true
config.log_level = :debug
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
config.active_record.dump_schema_after_migration = false
config.middleware.use('PartyFoul::Middleware')
config.secret_key_base = ENV["SECRET_KEY_BASE"]
宝石文件
gem 'rails', '4.2.5.1'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem "figaro"
gem 'geocoder'
gem 'seed_dump'
gem 'gmaps4rails'
gem 'devise'
gem 'puma'
gem 'activeadmin', github: 'activeadmin'
gem 'filterrific'
gem 'sprockets-rails', '2.3.3'
gem 'by_star', git: "git://github.com/radar/by_star"
gem 'colorize'
gem 'carrierwave'
gem 'mandrill-api'
gem 'active_model_serializers', '~> 0.10.0'
gem 'moving_average'
gem 'party_foul'
gem 'rails_serve_static_assets'
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development, :test do
gem 'byebug'
gem 'sqlite3'
end
查看
<script>
var map;
var infoWindow;
// Map Display options
function initMap()
map = new google.maps.Map(document.getElementById('map'),
zoom: 9,
center: lat: 42.05, lng: -70.25,
mapTypeId: google.maps.MapTypeId.SATELLITE,
scrollwheel: false,
scaleControl: false,
);
var polygons = [];
$.ajax(
url: '/species_filter',
type: "get", //send it through get method
data:target_species:$('#species_select').val(),
success: function(response)
console.log(response);
for (var i = 0; i < response.length ; i++)
polygons.push(new google.maps.Polygon(
paths: response[i].cfile,
strokeColor: '#F7F8FF',
strokeOpacity: 0.8,
strokeWeight: .35,
fillColor: response[i].color,
fillOpacity: 0.45,
editable: false,
map: map,
loc: response[i].location,
rep: response[i].reports,
mavg: response[i].movingavg
));
polygons[polygons.length-1].setMap(map);
var p = polygons[i];
google.maps.event.addListener(p, 'click', function (event)
console.log(this);
// console.log(location_reports);
var contentString = '<table><thead><tr><th>Date</th><th>Target Species</th><th>Vessel Name</th><th>Primary Method</th><th>Catch Total</th><th>Trip Summary</th></tr></thead><tbody><b>' + this.loc.short_name +'</b> <br>' + this.loc.long_name +'<br> <br>';
for(var j=0;j<this.rep.length; j++)
contentString += '<tr><td>' +this.rep[j].rep.date + '</td> <td>' +this.rep[j].rep.target_species + '</td><td>' +this.rep[j].vessel_name + '</td><td>' +this.rep[j].rep.primary_method + '</td><td>' +this.rep[j].rep.catch_total + '</td><td>' +this.rep[j].rep.trip_summary + '</td></tr>';
;
contentString +='</tbody></table>';
// Replace the info window's content and position.
infoWindow = new google.maps.InfoWindow;
infoWindow.setContent(contentString);
infoWindow.setPosition(event.latLng);
google.maps.event.addListener(infoWindow, 'domready', function()
var iwOuter = $('.gm-style-iw');
var iwBackground = iwOuter.prev();
// Remove the background shadow DIV
iwBackground.children(':nth-child(2)').css('display' : 'none');
// Remove the white background DIV
iwBackground.children(':nth-child(4)').css('display' : 'none');
iwOuter.parent().parent().css(left: '115px');
iwBackground.children(':nth-child(1)').attr('style', function(i,s) return s + 'left: 76px !important;');
iwBackground.children(':nth-child(3)').attr('style', function(i,s) return s + 'left: 155px !important;');
iwBackground.children(':nth-child(3)').find('div').children().css('box-shadow': 'rgba(72, 181, 233, 0.6) 0px 1px 6px', 'z-index' : '1');
var iwCloseBtn = iwOuter.next();
// Apply the desired effect to the close button
iwCloseBtn.css(
opacity: '1', // by default the close button has an opacity of 0.7
right: '44px', top: '8px', // button repositioning
// border: '7px solid #48b5e9', // increasing button border and new color
'border-radius': '13px', // circular effect
'box-shadow': '0 0 5px #3990B9' // 3D effect to highlight the button
);
iwCloseBtn.mouseout(function()
$(this).css(opacity: '1');
);
);
infoWindow.open(map);
);
google.maps.event.addListener(p, 'mouseover',function (event)
$("#locdetails").css("display", "block");
$( "#locdetails" ).append( "<div class='hoverrow'> <div class='hoverclass'>Location</div> <div class='hoverclass'>Average Catch Per Trip</div> <div class='hoverclass'>Reports posted past 7 days</div> </div> <div class='hoverrow'><div class='hoverclass'>"+ this.loc.short_name +"</div>" +"<div class='hoverclass'>" + this.mavg + "</div>"+"<div class='hoverclass'>" + this.rep.length + "</div></div>" );
map.data.revertStyle();
this.setOptions(
strokeColor: '#F7F8FF',
strokeWeight: 3 ,
fillOpacity: 0.75
);
);
google.maps.event.addListener(p, 'mouseout',function (event)
$("#locdetails").css("display", "none");
$( "#locdetails" ).empty();
map.data.revertStyle();
this.setOptions(
strokeColor: '#F7F8FF',
strokeOpacity: 0.8,
strokeWeight: .35,
fillOpacity: 0.5,
);
);
;
,
error: function(xhr)
);
$('#species_select').change(function()
initMap();
infoWindow.close();
);
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=""&callback=initMap">
</script>
日志
2017-01-13T15:34:39.920225+00:00 app[web.1]: Report Load (1.3ms) SELECT DISTINCT(tide) FROM "reports" WHERE "reports"."user_id" = $1 [["user_id", 3]]
2017-01-13T15:34:39.944172+00:00 app[web.1]: Location Load (1.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 15]]
2017-01-13T15:34:39.945545+00:00 app[web.1]: CACHE (0.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 6]]
2017-01-13T15:34:39.946432+00:00 app[web.1]: CACHE (0.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 15]]
2017-01-13T15:34:39.938746+00:00 app[web.1]: Location Load (2.7ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 6]]
2017-01-13T15:34:39.949118+00:00 app[web.1]: Location Load (0.8ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 7]]
2017-01-13T15:34:39.947292+00:00 app[web.1]: CACHE (0.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 6]]
2017-01-13T15:34:39.954280+00:00 app[web.1]: Rendered layouts/_navbar.html.erb (2.0ms)
2017-01-13T15:34:39.950113+00:00 app[web.1]: CACHE (0.0ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT 1 [["id", 7]]
2017-01-13T15:34:39.950936+00:00 app[web.1]: Rendered reports/index.html.erb within layouts/application (72.2ms)
2017-01-13T15:34:39.954731+00:00 app[web.1]: Completed 200 OK in 98ms (Views: 63.7ms | ActiveRecord: 20.2ms)
2017-01-13T15:34:40.100226+00:00 heroku[router]: at=info method=GET path="/assets/lighthouse2-ad6fdcbcefd4cb9d7254996e97d636d1010a916771ce0142bd8d2c0769f2b70b.jpg" host=currents.herokuapp.com request_id=887c16fd-2968-4772-8a3f-8ab815a033df fwd="199.253.243.3" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2017-01-13T15:34:41.085541+00:00 heroku[router]: at=info method=GET path="/maps" host=currents.herokuapp.com request_id=9b3b88a2-dd64-4fe0-b14b-c9393f4a1db3 fwd="199.253.243.3" dyno=web.1 connect=1ms service=25ms status=200 bytes=13348
2017-01-13T15:34:41.031038+00:00 app[web.1]: Started GET "/maps" for 199.253.243.3 at 2017-01-13 15:34:41 +0000
2017-01-13T15:34:41.034594+00:00 app[web.1]: Processing by MapsController#index as HTML
2017-01-13T15:34:41.036794+00:00 app[web.1]: User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 3]]
2017-01-13T15:34:41.048084+00:00 app[web.1]: Report Load (1.0ms) SELECT "reports".* FROM "reports"
2017-01-13T15:34:41.049807+00:00 app[web.1]: Rendered maps/index.html.erb within layouts/application (4.9ms)
2017-01-13T15:34:41.051861+00:00 app[web.1]: Rendered layouts/_navbar.html.erb (1.1ms)
2017-01-13T15:34:41.052294+00:00 app[web.1]: Completed 200 OK in 18ms (Views: 12.8ms | ActiveRecord: 1.8ms)
2017-01-13T15:34:41.220850+00:00 app[web.1]: Started GET "/species_filter?target_species=Any" for 199.253.243.3 at 2017-01-13 15:34:41 +0000
2017-01-13T15:34:41.224007+00:00 app[web.1]: Processing by MapsController#filter_by_species as */*
2017-01-13T15:34:41.224055+00:00 app[web.1]: Parameters: "target_species"=>"Any"
2017-01-13T15:34:41.239336+00:00 app[web.1]: User Load (13.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 3]]
2017-01-13T15:34:41.244027+00:00 app[web.1]: Location Load (1.2ms) SELECT "locations".* FROM "locations"
2017-01-13T15:34:41.255948+00:00 app[web.1]: (1.0ms) SELECT AVG("reports"."catch_keepers") AS average_catch_keepers, date AS date FROM "reports" WHERE "reports"."location_id" = $1 AND (date >= '2017-01-06') AND (date < '2017-01-13') GROUP BY "reports"."date" ORDER BY "reports"."date" DESC [["location_id", 1]]
2017-01-13T15:34:41.258770+00:00 app[web.1]: (0.8ms) SELECT AVG("reports"."catch_keepers") AS average_catch_keepers, date AS date FROM "reports" WHERE "reports"."location_id" = $1 AND (date >= '2017-01-05') AND (date < '2017-01-12') GROUP BY "reports"."date" [["location_id", 1]]
2017-01-13T15:34:41.258905+00:00 app[web.1]: ----moving average
2017-01-13T15:34:41.258927+00:00 app[web.1]: 0.0
2017-01-13T15:34:41.258951+00:00 app[web.1]: 0.0
2017-01-13T15:34:41.258931+00:00 app[web.1]: ----previous moving average
2017-01-13T15:34:41.258969+00:00 app[web.1]: ---movingavg
2017-01-13T15:34:41.258999+00:00 app[web.1]: :movingavg=>0.0, :color=>"#4562A8"
2017-01-13T15:34:41.261129+00:00 app[web.1]: Report Load (0.8ms) SELECT "reports".* FROM "reports" WHERE "reports"."location_id" = $1 AND (date >= '2017-01-06') AND (date < '2017-01-13') ORDER BY "reports"."date" DESC [["location_id", 1]]
2017-01-13T15:34:41.266026+00:00 app[web.1]: Completed 500 Internal Server Error in 42ms (ActiveRecord: 17.9ms)
2017-01-13T15:34:41.670858+00:00 heroku[router]: at=info method=GET path="/species_filter?target_species=Any" host=currents.herokuapp.com request_id=51400dbb-d5cb-4eef-a0fd-162e96339a1b fwd="199.253.243.3" dyno=web.1 connect=0ms service=424ms status=500 bytes=1669
2017-01-13T15:34:41.639677+00:00 app[web.1]:
2017-01-13T15:34:41.639685+00:00 app[web.1]: NoMethodError (undefined method `each' for #<ActionDispatch::Request::Session:0x007f05c5a61ae0>):
2017-01-13T15:34:41.639686+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/http/parameter_filter.rb:51:in `call'
2017-01-13T15:34:41.639686+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/http/parameter_filter.rb:11:in `filter'
2017-01-13T15:34:41.639687+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/issue_renderers/rails.rb:15:in `session'
2017-01-13T15:34:41.639687+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/issue_renderers/rack.rb:8:in `comment_options'
2017-01-13T15:34:41.639689+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/exception_handler.rb:31:in `run'
2017-01-13T15:34:41.639688+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/issue_renderers/base.rb:46:in `comment'
2017-01-13T15:34:41.639688+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/exception_handler.rb:67:in `update_issue'
2017-01-13T15:34:41.639689+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/processors/sync.rb:9:in `handle'
2017-01-13T15:34:41.639689+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/exception_handler.rb:10:in `handle'
2017-01-13T15:34:41.639690+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/middleware.rb:11:in `rescue in call'
2017-01-13T15:34:41.639691+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/party_foul-1.5.5/lib/party_foul/middleware.rb:8:in `call'
2017-01-13T15:34:41.639691+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb:35:in `block in call'
2017-01-13T15:34:41.639692+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb:34:in `catch'
2017-01-13T15:34:41.639692+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb:34:in `call'
2017-01-13T15:34:41.639693+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/etag.rb:24:in `call'
2017-01-13T15:34:41.639693+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/conditionalget.rb:25:in `call'
2017-01-13T15:34:41.639694+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/head.rb:13:in `call'
2017-01-13T15:34:41.639694+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
2017-01-13T15:34:41.639694+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/flash.rb:260:in `call'
2017-01-13T15:34:41.639695+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:225:in `context'
2017-01-13T15:34:41.639695+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:220:in `call'
2017-01-13T15:34:41.639696+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/cookies.rb:560:in `call'
2017-01-13T15:34:41.639696+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/query_cache.rb:36:in `call'
2017-01-13T15:34:41.639697+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
2017-01-13T15:34:41.639697+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
2017-01-13T15:34:41.639698+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
2017-01-13T15:34:41.639698+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:88:in `__run_callbacks__'
2017-01-13T15:34:41.639698+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
2017-01-13T15:34:41.639699+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2017-01-13T15:34:41.639699+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
2017-01-13T15:34:41.639700+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
2017-01-13T15:34:41.639700+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2017-01-13T15:34:41.639700+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/rack/logger.rb:38:in `call_app'
2017-01-13T15:34:41.639701+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/rack/logger.rb:20:in `block in call'
2017-01-13T15:34:41.639701+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/tagged_logging.rb:68:in `block in tagged'
2017-01-13T15:34:41.639701+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/tagged_logging.rb:26:in `tagged'
2017-01-13T15:34:41.639702+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/tagged_logging.rb:68:in `tagged'
2017-01-13T15:34:41.639702+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/rack/logger.rb:20:in `call'
2017-01-13T15:34:41.639707+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call'
2017-01-13T15:34:41.639709+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/engine.rb:518:in `call'
2017-01-13T15:34:41.639702+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2017-01-13T15:34:41.639707+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call'
2017-01-13T15:34:41.639708+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call'
2017-01-13T15:34:41.639708+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/static.rb:116:in `call'
2017-01-13T15:34:41.639709+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/application.rb:165:in `call'
2017-01-13T15:34:41.639707+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
2017-01-13T15:34:41.639709+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call'
2017-01-13T15:34:41.639710+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/configuration.rb:224:in `call'
2017-01-13T15:34:41.639711+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/server.rb:271:in `block in run'
2017-01-13T15:34:41.639710+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/server.rb:569:in `handle_request'
2017-01-13T15:34:41.639711+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/server.rb:406:in `process_client'
2017-01-13T15:34:41.639711+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/thread_pool.rb:114:in `call'
2017-01-13T15:34:41.639712+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/puma-3.4.0/lib/puma/thread_pool.rb:114:in `block in spawn_thread'
2017-01-13T15:34:41.639712+00:00 app[web.1]:
2017-01-13T15:34:41.639712+00:00 app[web.1]:
2017-01-13T16:09:59.608738+00:00 heroku[web.1]: Idling
2017-01-13T16:09:59.609122+00:00 heroku[web.1]: State changed from up to down
2017-01-13T16:10:00.308786+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-01-13T16:10:00.324473+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-01-13T16:10:00.325921+00:00 app[web.1]: === puma shutdown: 2017-01-13 16:10:00 +0000 ===
2017-01-13T16:10:00.325951+00:00 app[web.1]: - Goodbye!
2017-01-13T16:10:00.325992+00:00 app[web.1]: Exiting
2017-01-13T16:10:00.573756+00:00 heroku[web.1]: Process exited with status 0
【问题讨论】:
【参考方案1】:是否正在加载任何 jquery 类型的东西?引导程序?涡轮链接?等?
我会尝试将 CDN 粘贴到其中的通用 jquery 链接上,看看会发生什么……如果可行的话,你可以将你的东西移动到 CDN 主机上,看看它是否是特定的。
另外,你有没有放在那里的日志文件...
【讨论】:
没有 jquery 加载...引导加载正常。我现在将编辑以添加日志谢谢 高级引导程序是否有效或只是通用的?你用过水豚吗?您是否尝试过精简到一个非常基本的 jquery 文件,例如,一旦 $.document 加载,就会弹出一个 hello world 或打印到日志?$( document ).ready(function() console.log( "ready!" ); );
heroku 里面的东西...只是为了确保 heroku 没有拒绝一段代码?
感谢您的建议,我使用通用 jquery pop 进行了测试,它确实在 heroku 中工作。引导程序正在工作,包括高级。这表明代码块存在问题。任何要寻找的特定内容,因为这在开发环境中运行良好。我已编辑问题以包含视图。
多边形未加载,因此在 ajax 调用中失败。我没用过水豚现在研究一下。
我在想的唯一一件事是预编译设置,您在 rails 端缺少文件设置..但他们可能已经贬值了...***.com/questions/8012434/…【参考方案2】:
404 错误是由于在 application.js 中包含此文件 //= require map_theme/vendor/jquery.localize
最终问题/500 错误与一段代码有关,并且错误地播种了生产数据库。我有 ID 与开发环境不同的位置。所以代码找不到文件,jquery失败了。
【讨论】:
以上是关于Heroku jQuery JavaScript 库未加载 - 404 错误的主要内容,如果未能解决你的问题,请参考以下文章
jQuery 适用于 Heroku,但不适用于 Rails localhost
Rails - jQuery 不能在 Heroku 的生产环境中工作
将 Rails 应用程序部署到 Heroku 后,不显示 JQuery 函数中的图像