预编译后Rails javascript资产丢失 [英] Rails javascript asset missing after precompile

查看:206
本文介绍了预编译后Rails javascript资产丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Rails指南说:


如果生产中缺少预编译文件,您将获得
Sprockets :: Helpers :: RailsHelper :: AssetPaths :: AssetNotPrecompiledError
异常,指示丢失文件的名称。

If there are missing precompiled files in production you will get an Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError exception indicating the name of the missing file(s).

我执行:

bundle exec rake assets:precompile

但是我没有收到任何错误,我的javascript文件 manifest.yml 中缺少。它也没有出现在 public / assets 中,因此问题仅出在生产上。

however I don't get any error, and my javascript file is missing in the manifest.yml. Also it's not appearing in public/assets, so the problem is only on production.

我在 application.js

//= require formalize/jquery-formalize

我缺少什么?

谢谢。

推荐答案

实际上需要做两件事:

config.assets.precompile += %w( *.js *.css )

如上所述

as described here, and

config.serve_static_assets = true

用于本地生产测试时使用

for local production testing when using

rail s

当然使用

rake assets:precompile

然而在我的情况下 - 如果没有config.assets.precompile,这将没有任何效果,因为清单不包含对我的javascript文件的任何引用。

however in my case - without config.assets.precompile this would have no effect since the manifest didn't contain any reference to my javascript file.

HTH。

这篇关于预编译后Rails javascript资产丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆