我前几天将我的rails 4.1.7应用程序发布到Heroku,css似乎工作正常。
但javascript文件部分响应。我有一个警报(" In Charts-other.js");
*$(document).ready(function(){
alert("in Charts-Other.js");...
...*
得到一些回应,什么都没有。
解决: 在application.js中,我将带有错误的文件移到了底部。一切似乎都很好。
在Heroku应用程序链接中,我可以通过以下方式直接访问所有文件:/assets/clever/java_script_files.js
配置/环境/ 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
配置/ 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
/ Gemfile中
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
任何帮助都将受到高度赞赏 谢谢。 埃尔达尔
答案 0 :(得分:3)
<强>解决:强> 在application.js中,我将带有错误的文件移到了底部。 一切似乎都很好。
显然,在生产模式下,带有警告/错误的文件的行为方式不同。
答案 1 :(得分:0)
在我的情况下,我需要添加到config / application.rb:
config.assets.precompile += %w(*.js)