当我推送到Heroku时,我遇到了预编译资产的问题,安装了Bootstrap并且文件' affix.js'找不到。 我试着添加:
//= require bootstrap/affix
但它没有帮助,任何人都遇到了同样的问题?
我过去曾经遇到过这个问题,通常更新bootstrap修复它。不是这次:
GEMFILE:
# Assets
gem 'bootstrap-sass', '~> 3.3.5'
gem 'sass-rails', '>= 3.2'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'font-awesome-sass'
gem 'nprogress-rails'
ERROR:
remote: rake aborted!
remote: Sprockets::FileNotFound: could not find file:
/tmp/build_7160395b09b71ebb83ef5bf51eb32d75/vendor/bundle/ruby/2.2.0/gems/bootstrap-sass-3.3.5.1/assets/javascripts/bootstrap/affix.js remote:tmp/build_2e50ddbbbfb3469acb16fa727d62c302/vendor/bundle/ruby/2.2.0/gems/sprockets-3.3.2/lib/sprockets/loader.rb:95:in `load_from_unloaded'
remote:/tmp/build_2e50ddbbbfb3469acb16fa727d62c302/vendor/bundle/ruby/2.2.0/gems/sprockets-3.3.2/lib/sprockets/loader.rb:60:in block in load'
remote:/tmp/build_2e50ddbbbfb3469acb16fa727d62c302/vendor/bundle/ruby/2.2.0/gems/sprockets-3.3.2/lib/sprockets/loader.rb:286:in
fetch_asset_from_dependency_cache'
答案 0 :(得分:1)
好的,所以这很有效:
rake assets:precompile
git add .
git commit -m "precompile all assets"
git push heroku-or-whatever-branch
我仍然无法解释任何事情......
答案 1 :(得分:0)
您的资产可能与以前的部署相混淆。要重置资产并在heroku上启动一个干净的预编译,请在config / initializers / assets.rb文件中增加Rails.application.config.assets.version。
Rails.application.config.assets.version = '1.1'