我正在使用 Rails 3.2.3 并部署到 Heroku 的 Cedar Stack,但我的资产管道和编译所需的 jQuery UI 文件时遇到问题。
具体来说,这个问题体现在我认为相关的两个独立问题上:
1)在开发中我的下拉按钮不起作用,但在生产中它们起作用
2)在开发中,我的日期选择器和滑块不起作用,它们在生产中也不起作用。<script src="/assets/jquery-ui.js" type="text/javascript"></script>
但是,如果我在视图顶部调用 javascript ( ),则日期选择器和滑块在开发中有效,但在生产中无效
我曾尝试在本地以及在 slug 编译期间编译资产,但无济于事。
我的应用程序.js:
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require bootstrap
//= require_tree .
我的宝石文件:
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'bootstrap-sass', '2.0.0'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.5'
gem 'date_validator'
gem 'jquery_datepicker'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.9.0'
gem 'annotate', '~> 2.4.1.beta'
end
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '1.4.0'
end
group :production do
gem 'pg', '0.12.2'
end
我的配置/环境/development.rb
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true
我的配置/环境/production.rb:
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
# Generate digests for assets URLs
config.assets.digest = true
我的布局 application.html.erb:
<%= javascript_include_tag "application" %>