Rails 4-JavaScript文件未在生产环境中加载,但在本地运行良好. (Heroku)
作者:互联网
前几天,我将Rails 4.1.7应用程序发布到Heroku中,css似乎运行良好.
但是javascript文件部分响应.我有一个警报(“在Charts-other.js中”);
*$(document).ready(function(){
alert("in Charts-Other.js");...
...*
得到一些回应,什么也没有.
解决了:
在application.js中,我将带有错误的文件移至底部.一切似乎都正常.
在Heroku应用程序链接中,我可以通过以下方式直接访问所有文件:/assets/clever/java_script_files.js
config / environments / production.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif *.svg *.ico *.eot *.ttf)
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = true
config.assets.js_compressor = :uglifier
config.assets.compile = true
config.assets.digest = true
config.log_level = :info
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
config.active_record.dump_schema_after_migration = false
end
config / application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
module Website
class Application < Rails::Application
config.assets.paths << Rails.root.join('vendor','assets', 'fonts','clever')
config.assets.enabled = true
config.serve_static_assets = true
end
end
/宝石文件
source 'https://rubygems.org'
ruby '2.2.0'
gem 'sprockets', '~> 2.12.3'
gem 'rails', '4.1.7'
gem 'pg'
gem 'therubyracer'
gem 'jquery-rails'
gem 'jquery-ui-rails', '~> 5.0.3'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'httparty', '~> 0.13.3'
gem 'nokogiri'
gem 'byebug'
gem 'mechanize', '~> 2.7.3'
gem 'watir', '~> 5.0.0'
gem 'watir-webdriver', '~> 0.6.11'
gem 'unicorn'
gem 'sidekiq', '~> 3.3.0'
gem 'sinatra', require: false
gem 'slim'
gem "bcrypt", :require => "bcrypt"
gem 'shoulda-matchers', '~> 2.7.0'
gem 'font-awesome-rails', '~> 4.2.0.0', group: :production
gem 'curb', '~> 0.8.6'
gem 'chronic', '~> 0.10.2'
gem 'bunny', '~> 1.6.3'
gem 'jquery-turbolinks'
group :production do
gem 'rails_12factor'
end
group :assets do
gem 'sass-rails', '~> 4.0.3'
gem 'coffee-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'wrap-bootstrap-rails', '~> 0.0.3'
end
/app/assets/javascript/application.js
//= require jquery
//= require jquery_ujs
//= require jquery.turbolinks
//= require clever/jquery-2.1.0.min.js
//= require clever/jquery-migrate-1.2.1.min.js
//= require clever/bootstrap.min.js
//= require clever/jquery-ui.min.js
//= require clever/jquery.sparkline.min.js
//= require clever/jquery.knob.modified.min.js
//= require clever/uncompressed/d3.js
//= require clever/uncompressed/xcharts.js
//= require clever/jquery.easy-pie-chart.min.js
//= require clever/raphael.min.js
//= require clever/justgage.1.0.1.min.js
//= require clever/custom.min.js
//= require clever/core.min.js
//= require clever/pages/charts-xcharts.js
//= require clever/pages/charts-other.js
//= require clever/pages/charts-flot.js
//= require clever/uncompressed/jquery.flot.js
//= require clever/pages/ui-sliders-progress.js
//= require clever/jquery.ui.touch-punch.min.js
//= require clever/jquery.sparkline.min.js
//= require clever/fullcalendar.min.js
//= require clever/jquery.flot.pie.min.js
//= require clever/jquery.flot.stack.min.js
//= require clever/jquery.flot.resize.min.js
//= require clever/jquery.flot.time.min.js
//= require clever/jquery.flot.spline.min.js
//= require clever/jquery.autosize.min.js
//= require clever/jquery.placeholder.min.js
//= require clever/moment.min.js
//= require clever/daterangepicker.min.js
//= require clever/jquery.easy-pie-chart.min.js
//= require clever/jquery.dataTables.min.js
//= require clever/dataTables.bootstrap.min.js
//= require clever/raphael.min.js
//= require clever/morris.min.js
//= require clever/jquery-jvectormap-1.2.2.min.js
//= require clever/uncompressed/jquery-jvectormap-world-mill-en.js
//= require clever/uncompressed/gdp-data.js
//= require clever/gauge.min.js
//= require clever/uncompressed/justgage.1.0.1.js
//= require clever/pages/index.min.js
任何帮助将不胜感激
谢谢.
埃尔达
解决方法:
解决了:
在application.js中,我将带有错误的文件移至底部.
一切似乎都正常.
显然,在生产模式下,带有警告/错误的文件的行为有所不同.
标签:heroku,ruby-on-rails-4,ruby,javascript,ruby-on-rails 来源: https://codeday.me/bug/20191120/2047191.html