我有一个在开发中运行良好的应用程序,但是当我将它推送到 Heroku 时,Mercury Editor 不起作用。这是浏览器报告的内容:
GET http://domain.com/javascripts/jquery-1.7.js 404 (Not Found)
然后当然:
Uncaught ReferenceError: $ is not defined mercury-b3d36be256f77d3d2190b11910f92c7e.js:1
(anonymous function)
Uncaught TypeError: undefined is not a function
(anonymous function)
Chrome 控制台的来源面板:
<title>Mercury Editor</title>
<link href="/assets/mercury-1c5e058864b28582ab79e4fb2519dceb.css" media="screen" rel="stylesheet" />
<script src="/javascripts/jquery-1.7.js"></script>
<script src="/assets/mercury-b3d36be256f77d3d2190b11910f92c7e.js"></script>
我的宝石文件:
source 'https://rubygems.org'
ruby '2.1.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.3'
gem 'bootstrap-sass', '~> 3.1.1'
gem 'bcrypt-ruby', '3.1.2'
gem 'faker', '1.1.2'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'
gem 'mercury-rails', git: 'https://github.com/jejacks0n/mercury.git'
gem 'jquery-migrate-rails'
gem 'friendly_id', '~> 5.0.0'
gem 'paperclip'
gem 'aws-sdk'
gem 'rmagick', '2.13.2'
gem 'figaro'
# Use sqlite3 as the database for Active Record
group :development do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
gem 'factory_girl_rails', '4.2.1'
end
# Use SCSS for stylesheets
gem 'sass-rails', '4.0.1'
gem 'sprockets', '2.11.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '2.1.1'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '4.0.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails', '3.0.4'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks', '1.1.1'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '1.0.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
应用程序.js:
//= require jquery
//= require jquery_ujs
//= require jquery-migrate-min
//= require turbolinks
//= require bootstrap.min
//= require_tree .
我不知道什么会加载 jquery 1.7,但我认为它可能是 Mercury Editor 的依赖项,因为我必须为它安装jquery-migrate-rails。我不知道为什么它在开发中有效,但在 Heroku 上无效。似乎它不包含在资产管道中。