作者:没有完美的谎言 | 来源:互联网 | 2023-09-06 18:04
HerokuandmyproductionenvironmentarenotloadingthejQueryJavaScriptLibraryleadingtothefo
Heroku and my production environment are not loading the jQuery Javascript Library leading to the following "Failed to load resource: the server responded with a status of 404 (Not Found)".
Heroku和我的生产环境没有加载jQuery Javascript库,导致以下“无法加载资源:服务器响应状态为404(未找到)”。
All the research I have done point to a asset pipeline issues, but i have confirmed the assets are being precompiled localy and delivered to Heroku.
我所做的所有研究都指向资产管道问题,但我已经确认资产正在进行预编译并交付给Heroku。
I have performed / tested the following and still having issues.
- arranged my asset order in application.js
在application.js中安排了我的资产订单
- changed production.rb: config.assets.compile = true , from default config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
更改了production.rb:config.assets.compile = true,来自默认的config.serve_static_files = ENV ['RAILS_SERVE_STATIC_FILES']。现在?
- ran the command: rake assets:precompile then git push heroku master
运行命令:rake assets:precompile然后git push heroku master
- ran the command: RAILS_ENV=production bundle exec rake assets:precompile
运行命令:RAILS_ENV =生产包exec rake assets:预编译
- ran the command: heroku run rake assets:precompile --app appName
运行命令:heroku run rake assets:precompile --app appName
- added the gem 'rails_serve_static_assets' as mentioned in heroku documentation
添加了heroku文档中提到的gem“rails_serve_static_assets”
- precompiled production assets and pushhed and compiled on Heroku. RAILS_ENV=production bundle exec rake assets:precompile
预编译的生产资产,并在Heroku上进行推送和编译。 RAILS_ENV =生产包exec rake资产:预编译
- Debugged in Heroku: confirmed precompiled assets loaded to public/assets $ heroku run bash $ ls public/assets
在Heroku中调试:已确认加载到公共/资产的预编译资产$ heroku运行bash $ ls public / assets
- Still getting the 404 error in my console "Failed to load resource: the server responded with a status of 404 (Not Found)" specifically naming the Jquery Javascript library. Hit a road block on what I am doing wrong. Any help is appreciated.
我的控制台仍然出现404错误“无法加载资源:服务器响应状态为404(未找到)”,专门命名Jquery Javascript库。我做错了什么路障。任何帮助表示赞赏。
My problem seems similar to this issue with no answer although i am getting a 404 error.
Jquery not working in Production & Heroku but works perfectly well in development
Jquery不在Production&Heroku工作,但在开发中运行良好
code
application.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
production.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"]
gemfile
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
view
"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 #):
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
2 个解决方案