我的javascript似乎都无法在制作中使用。
不幸的是那些问题: JavaScript not working in Rails app in production https://stackoverflow.com/questions/27470207/rails-javascript-working-in-development-but-not-in-production Rails JavaScript views not working in production Rails 3.2.3 JavaScript suddenly stopped working 要么没有答案,要么解决方案没有帮助。
在开发环境中,我所有的JS都工作得非常好。然而,在生产中,即使是简单的东西,我自己也没有工作(我使用的是带有很多JS的引导模板)。
我收到的唯一错误就是这个
Uncaught ReferenceError: angular is not defined
angular.module("app",[require("./home").name]);
但它不应该影响javascript的其余部分。这里环境/ production.rb:
config.cache_classes = true
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
我尝试将编译设置为true,但它没有帮助。
这是我在initializers / assets.rb中添加的内容:
Rails.application.config.assets.precompile += %w( *.js *.css *.scss *.coffee )
也没有帮助。
我运行rake资产:手动预编译(虽然我的capistrano puma脚本也是这样做的:
DEBUG [b487d8df] Command: cd /home/deploy/apps/mosflash/releases/20150924201201 && ( RAILS_ENV=production ~/.rvm/bin/rvm default do bundle exec rake assets:precompile )
有人能暗示我走向正确的方向吗?